summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-03 00:09:26 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-09-03 00:09:26 +0200
commit4912e7a3fd0c78d630b8e571d35c2968eb4b586c (patch)
tree02dbeda0639805e7a8eeb858c8085472b0e9c4eb /Lib/test
parent329ca7118f64f5d8dc992146f307b04e68915430 (diff)
parent1c4055208758c6e85f00674eae24e0351b659c5a (diff)
downloadcpython-git-4912e7a3fd0c78d630b8e571d35c2968eb4b586c.tar.gz
Merge 3.4 (test_warnings)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_warnings.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index c7d2e5cfbb..03d9958f69 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.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):