[Python-checkins] cpython: Issue #23027: test_warnings now passes all tests when run it with -Werror.
berker.peksag
python-checkins at python.org
Wed Apr 8 16:38:22 CEST 2015
https://hg.python.org/cpython/rev/e64197dad303
changeset: 95485:e64197dad303
user: Berker Peksag <berker.peksag at gmail.com>
date: Wed Apr 08 17:38:39 2015 +0300
summary:
Issue #23027: test_warnings now passes all tests when run it with -Werror.
files:
Lib/test/test_warnings.py | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -456,17 +456,20 @@
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 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(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 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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list