]> granicus.if.org Git - python/commitdiff
Clean up warnings filter use in test_global by no longer having it be a
authorBrett Cannon <bcannon@gmail.com>
Sat, 20 Mar 2010 21:48:19 +0000 (21:48 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sat, 20 Mar 2010 21:48:19 +0000 (21:48 +0000)
module-level manipulation of the filter.

Lib/test/test_global.py

index 823f2c544d21adfeea8d26f81c3e86144a7d0c83..a98e339aa2a610561c3397f52729b250a0266da7 100644 (file)
@@ -1,13 +1,22 @@
 """Verify that warnings are issued for global statements following use."""
 
-from test.support import run_unittest, check_syntax_error
+from test.support import run_unittest, check_syntax_error, check_warnings
 import unittest
 
 import warnings
-warnings.filterwarnings("error", module="<test string>")
+
 
 class GlobalTests(unittest.TestCase):
 
+    def setUp(self):
+        self._warnings_manager = check_warnings()
+        self._warnings_manager.__enter__()
+        warnings.filterwarnings("error", module="<test string>")
+
+    def tearDown(self):
+        self._warnings_manager.__exit__(None, None, None)
+
+
     def test1(self):
         prog_text_1 = """\
 def wrong1():