[Python-checkins] cpython (3.5): Reapplied change to test_warnings.py to test_warnings/__init__.py.
steve.dower
python-checkins at python.org
Mon Sep 7 07:38:07 CEST 2015
https://hg.python.org/cpython/rev/56c10f7e0aed
changeset: 97734:56c10f7e0aed
branch: 3.5
user: Steve Dower <steve.dower at microsoft.com>
date: Sun Sep 06 22:30:40 2015 -0700
summary:
Reapplied change to test_warnings.py to test_warnings/__init__.py.
files:
Lib/test/test_warnings/__init__.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py
--- a/Lib/test/test_warnings/__init__.py
+++ b/Lib/test/test_warnings/__init__.py
@@ -44,6 +44,7 @@
"""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 @@
# 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):
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list