mirror of https://github.com/python/cpython.git
Merge 3.4 (test_warnings)
This commit is contained in:
commit
4912e7a3fd
|
@ -44,6 +44,7 @@ class BaseTest:
|
||||||
"""Basic bookkeeping required for testing."""
|
"""Basic bookkeeping required for testing."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.old_unittest_module = unittest.case.warnings
|
||||||
# The __warningregistry__ needs to be in a pristine state for tests
|
# The __warningregistry__ needs to be in a pristine state for tests
|
||||||
# to work properly.
|
# to work properly.
|
||||||
if '__warningregistry__' in globals():
|
if '__warningregistry__' in globals():
|
||||||
|
@ -55,10 +56,15 @@ def setUp(self):
|
||||||
# The 'warnings' module must be explicitly set so that the proper
|
# The 'warnings' module must be explicitly set so that the proper
|
||||||
# interaction between _warnings and 'warnings' can be controlled.
|
# interaction between _warnings and 'warnings' can be controlled.
|
||||||
sys.modules['warnings'] = self.module
|
sys.modules['warnings'] = self.module
|
||||||
|
# Ensure that unittest.TestCase.assertWarns() uses the same warnings
|
||||||
|
# module than warnings.catch_warnings(). Otherwise,
|
||||||
|
# warnings.catch_warnings() will be unable to remove the added filter.
|
||||||
|
unittest.case.warnings = self.module
|
||||||
super(BaseTest, self).setUp()
|
super(BaseTest, self).setUp()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
sys.modules['warnings'] = original_warnings
|
sys.modules['warnings'] = original_warnings
|
||||||
|
unittest.case.warnings = self.old_unittest_module
|
||||||
super(BaseTest, self).tearDown()
|
super(BaseTest, self).tearDown()
|
||||||
|
|
||||||
class PublicAPITests(BaseTest):
|
class PublicAPITests(BaseTest):
|
||||||
|
|
Loading…
Reference in New Issue