]> granicus.if.org Git - python/commitdiff
Merged revisions 70979 via svnmerge from
authorBrett Cannon <bcannon@gmail.com>
Wed, 1 Apr 2009 20:27:29 +0000 (20:27 +0000)
committerBrett Cannon <bcannon@gmail.com>
Wed, 1 Apr 2009 20:27:29 +0000 (20:27 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r70979 | brett.cannon | 2009-04-01 13:25:48 -0700 (Wed, 01 Apr 2009) | 3 lines

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

Lib/test/test_warnings.py

index 49f3d3a7b776c1f15c8b158c9c9f566ba268ae6b..d04c3ddfa9c893da8b83726b553eda7e1143ba04 100644 (file)
@@ -470,14 +470,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.