summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-04-08 14:38:39 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-04-08 14:38:39 (GMT)
commitb8e973f9374524b3065e70bd265da2a8901b4638 (patch)
treed03a93a8f8d574182e06b3a745d50675880f95d4
parentd09620839c3295d2b912c193cfc5a920d17f88cd (diff)
downloadcpython-b8e973f9374524b3065e70bd265da2a8901b4638.zip
cpython-b8e973f9374524b3065e70bd265da2a8901b4638.tar.gz
cpython-b8e973f9374524b3065e70bd265da2a8901b4638.tar.bz2
Issue #23027: test_warnings now passes all tests when run it with -Werror.
-rw-r--r--Lib/test/test_warnings.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 9ac2139..303ca71 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -456,17 +456,20 @@ class WarnTests(BaseTest):
self.assertIn('category must be a Warning subclass, not ',
str(cm.exception))
- with self.assertWarns(MyWarningClass) as cm:
- self.module.warn('good warning category', MyWarningClass)
- self.assertEqual('good warning category', str(cm.warning))
-
- with self.assertWarns(UserWarning) as cm:
- self.module.warn('good warning category', None)
- self.assertEqual('good warning category', str(cm.warning))
-
- with self.assertWarns(MyWarningClass) as cm:
- self.module.warn('good warning category', MyWarningClass)
- self.assertIsInstance(cm.warning, Warning)
+ with original_warnings.catch_warnings(module=self.module):
+ self.module.resetwarnings()
+ self.module.filterwarnings('default')
+ with self.assertWarns(MyWarningClass) as cm:
+ self.module.warn('good warning category', MyWarningClass)
+ self.assertEqual('good warning category', str(cm.warning))
+
+ with self.assertWarns(UserWarning) as cm:
+ self.module.warn('good warning category', None)
+ self.assertEqual('good warning category', str(cm.warning))
+
+ with self.assertWarns(MyWarningClass) as cm:
+ self.module.warn('good warning category', MyWarningClass)
+ self.assertIsInstance(cm.warning, Warning)
class CWarnTests(WarnTests, unittest.TestCase):
module = c_warnings