summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-02-28 23:49:19 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-02-28 23:49:19 (GMT)
commit2922ea8235c183cb35c3415b5888967af55812fa (patch)
tree42e315ecc3ff6956756ccbaff13a9b0dfebabe47
parent3dd5ad3b4f1e7be153d272a2ac3848028a6c306b (diff)
downloadcpython-2922ea8235c183cb35c3415b5888967af55812fa.zip
cpython-2922ea8235c183cb35c3415b5888967af55812fa.tar.gz
cpython-2922ea8235c183cb35c3415b5888967af55812fa.tar.bz2
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.
-rw-r--r--Lib/test/output/test_global1
-rw-r--r--Lib/test/test_global.py6
-rw-r--r--Lib/test/test_grammar.py3
3 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/output/test_global b/Lib/test/output/test_global
index 0c96cfa..ba92813 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 c60d0c7..b41b7d4 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 587d7ec..75a55b9 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="<string>")
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__']