summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_warnings
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2015-09-07 05:30:40 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2015-09-07 05:30:40 (GMT)
commit96d49438465b78abf1f09f190ee46793dcd672b8 (patch)
treec101c7437c720c6ddcaa7e719db60bed7d72025b /Lib/test/test_warnings
parentf35bd306ffa2c05a1297435bb15cd3b4d47b3977 (diff)
downloadcpython-96d49438465b78abf1f09f190ee46793dcd672b8.zip
cpython-96d49438465b78abf1f09f190ee46793dcd672b8.tar.gz
cpython-96d49438465b78abf1f09f190ee46793dcd672b8.tar.bz2
Reapplied change to test_warnings.py to test_warnings/__init__.py.
Diffstat (limited to 'Lib/test/test_warnings')
-rw-r--r--Lib/test/test_warnings/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py
index 991a249..cea9c57 100644
--- a/Lib/test/test_warnings/__init__.py
+++ b/Lib/test/test_warnings/__init__.py
@@ -44,6 +44,7 @@ class BaseTest:
"""Basic bookkeeping required for testing."""
def setUp(self):
+ self.old_unittest_module = unittest.case.warnings
# The __warningregistry__ needs to be in a pristine state for tests
# to work properly.
if '__warningregistry__' in globals():
@@ -55,10 +56,15 @@ class BaseTest:
# The 'warnings' module must be explicitly set so that the proper
# interaction between _warnings and 'warnings' can be controlled.
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()
def tearDown(self):
sys.modules['warnings'] = original_warnings
+ unittest.case.warnings = self.old_unittest_module
super(BaseTest, self).tearDown()
class PublicAPITests(BaseTest):