From: Brett Cannon Date: Wed, 1 Apr 2009 20:25:48 +0000 (+0000) Subject: test_warnings ironically had a single test that was not protecting the warnings X-Git-Tag: v2.7a1~1630 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce3d22144781845784d17fa3b4b3e034d2d448f0;p=python test_warnings ironically had a single test that was not protecting the warnings filter and was resetting it. --- diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index bc177ad9e7..bb2fb5ff25 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -460,14 +460,14 @@ class _WarningsTests(BaseTest): self.failUnless(text in result) def test_showwarning_not_callable(self): - self.module.filterwarnings("always", category=UserWarning) - old_showwarning = self.module.showwarning - self.module.showwarning = 23 - try: - self.assertRaises(TypeError, self.module.warn, "Warning!") - finally: - self.module.showwarning = old_showwarning - self.module.resetwarnings() + with original_warnings.catch_warnings(module=self.module): + self.module.filterwarnings("always", category=UserWarning) + old_showwarning = self.module.showwarning + self.module.showwarning = 23 + try: + self.assertRaises(TypeError, self.module.warn, "Warning!") + finally: + self.module.showwarning = old_showwarning def test_show_warning_output(self): # With showarning() missing, make sure that output is okay. diff --git a/Misc/NEWS b/Misc/NEWS index c4474522fb..08552bf314 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -730,6 +730,8 @@ Extension Modules Tests ----- +- Fix test_warnings to no longer reset the warnings filter. + - Fix test_logging to no longer reset the warnings filter. - Issue #5635: Fix running test_sys with tracing enabled.