From: Jeremy Hylton Date: Wed, 28 Feb 2001 23:49:19 +0000 (+0000) Subject: Add test case for global stmt at module level. X-Git-Tag: v2.1b1~94 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2922ea8235c183cb35c3415b5888967af55812fa;p=python Add test case for global stmt at module level. Fix test_grammar so that it ignores warning about global stmt at module level in exec. --- diff --git a/Lib/test/output/test_global b/Lib/test/output/test_global index 0c96cfa5db..ba92813709 100644 --- a/Lib/test/output/test_global +++ b/Lib/test/output/test_global @@ -2,3 +2,4 @@ test_global got SyntaxError as expected got SyntaxError as expected got SyntaxError as expected +got SyntaxError as expected diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py index c60d0c7b29..b41b7d4cc8 100644 --- a/Lib/test/test_global.py +++ b/Lib/test/test_global.py @@ -37,3 +37,9 @@ def wrong3(): global x """ compile_and_catch_warning(prog_text_3) + +prog_text_4 = """ +global x +x = 2 +""" +compile_and_catch_warning(prog_text_4) diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 587d7ecfcf..75a55b963c 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -411,6 +411,9 @@ if g.has_key('__builtins__'): del g['__builtins__'] if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' g = {} l = {} + +import warnings +warnings.filterwarnings("ignore", "global statement", module="") exec 'global a; a = 1; b = 2' in g, l if g.has_key('__builtins__'): del g['__builtins__'] if l.has_key('__builtins__'): del l['__builtins__']