diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-04-08 14:38:39 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-04-08 14:38:39 (GMT) |
commit | b8e973f9374524b3065e70bd265da2a8901b4638 (patch) | |
tree | d03a93a8f8d574182e06b3a745d50675880f95d4 | |
parent | d09620839c3295d2b912c193cfc5a920d17f88cd (diff) | |
download | cpython-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.py | 25 |
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 |