diff options
Diffstat (limited to 'Lib/test/test_global.py')
-rw-r--r-- | Lib/test/test_global.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py index abcb193e5ee..37ec67255a5 100644 --- a/Lib/test/test_global.py +++ b/Lib/test/test_global.py @@ -1,12 +1,21 @@ """Verify that warnings are issued for global statements following use.""" -from test.test_support import run_unittest, check_syntax_error +from test.support import run_unittest, check_syntax_error, check_warnings import unittest import warnings 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(): @@ -20,7 +29,7 @@ def wrong1(): def test2(self): prog_text_2 = """\ def wrong2(): - print x + print(x) global x """ check_syntax_error(self, prog_text_2) @@ -28,7 +37,7 @@ def wrong2(): def test3(self): prog_text_3 = """\ def wrong3(): - print x + print(x) x = 2 global x """ |