[Python-checkins] r70979 - in python/trunk: Lib/test/test_warnings.py Misc/NEWS

brett.cannon python-checkins at python.org
Wed Apr 1 22:25:48 CEST 2009


Author: brett.cannon
Date: Wed Apr  1 22:25:48 2009
New Revision: 70979

Log:
test_warnings ironically had a single test that was not protecting the warnings
filter and was resetting it.


Modified:
   python/trunk/Lib/test/test_warnings.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/test/test_warnings.py
==============================================================================
--- python/trunk/Lib/test/test_warnings.py	(original)
+++ python/trunk/Lib/test/test_warnings.py	Wed Apr  1 22:25:48 2009
@@ -460,14 +460,14 @@
         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.

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Apr  1 22:25:48 2009
@@ -730,6 +730,8 @@
 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.


More information about the Python-checkins mailing list