Commit b8e973f9 authored by Berker Peksag's avatar Berker Peksag

Issue #23027: test_warnings now passes all tests when run it with -Werror.

parent d0962083
...@@ -456,17 +456,20 @@ class WarnTests(BaseTest): ...@@ -456,17 +456,20 @@ class WarnTests(BaseTest):
self.assertIn('category must be a Warning subclass, not ', self.assertIn('category must be a Warning subclass, not ',
str(cm.exception)) str(cm.exception))
with self.assertWarns(MyWarningClass) as cm: with original_warnings.catch_warnings(module=self.module):
self.module.warn('good warning category', MyWarningClass) self.module.resetwarnings()
self.assertEqual('good warning category', str(cm.warning)) self.module.filterwarnings('default')
with self.assertWarns(MyWarningClass) as cm:
with self.assertWarns(UserWarning) as cm: self.module.warn('good warning category', MyWarningClass)
self.module.warn('good warning category', None) self.assertEqual('good warning category', str(cm.warning))
self.assertEqual('good warning category', str(cm.warning))
with self.assertWarns(UserWarning) as cm:
with self.assertWarns(MyWarningClass) as cm: self.module.warn('good warning category', None)
self.module.warn('good warning category', MyWarningClass) self.assertEqual('good warning category', str(cm.warning))
self.assertIsInstance(cm.warning, Warning)
with self.assertWarns(MyWarningClass) as cm:
self.module.warn('good warning category', MyWarningClass)
self.assertIsInstance(cm.warning, Warning)
class CWarnTests(WarnTests, unittest.TestCase): class CWarnTests(WarnTests, unittest.TestCase):
module = c_warnings module = c_warnings
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment