summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-03-02 01:48:16 +0000
committerTim Peters <tim.peters@gmail.com>2001-03-02 01:48:16 +0000
commitfc35de409bc3606838daddf5fc30d3c0c3cfee11 (patch)
treed8ba8657063ea1965081163b7b9f4add14fc8c36 /Lib
parent7a25765f48dbd6697c346559f75aa1ce08d91a5a (diff)
downloadcpython-git-fc35de409bc3606838daddf5fc30d3c0c3cfee11.tar.gz
test_global was broken by some recent checkin. Repairing.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/output/test_global2
-rw-r--r--Lib/test/test_global.py22
2 files changed, 15 insertions, 9 deletions
diff --git a/Lib/test/output/test_global b/Lib/test/output/test_global
index ba92813709..a427a29cb0 100644
--- a/Lib/test/output/test_global
+++ b/Lib/test/output/test_global
@@ -2,4 +2,4 @@ test_global
got SyntaxError as expected
got SyntaxError as expected
got SyntaxError as expected
-got SyntaxError as expected
+as expected, no SyntaxError
diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py
index b41b7d4cc8..fb10533ae4 100644
--- a/Lib/test/test_global.py
+++ b/Lib/test/test_global.py
@@ -1,4 +1,4 @@
-"""Verify that warnings are issued for global statements following use"""
+"""Verify that warnings are issued for global statements following use."""
from test_support import check_syntax
@@ -6,13 +6,19 @@ import warnings
warnings.filterwarnings("error", module="<test code>")
-def compile_and_catch_warning(text):
+def compile_and_check(text, should_fail=1):
try:
compile(text, "<test code>", "exec")
except SyntaxError, msg:
- print "got SyntaxError as expected"
+ if should_fail:
+ print "got SyntaxError as expected"
+ else:
+ print "raised unexpected SyntaxError:", text
else:
- print "expected SyntaxError"
+ if should_fail:
+ print "should have raised SyntaxError:", text
+ else:
+ print "as expected, no SyntaxError"
prog_text_1 = """
def wrong1():
@@ -21,14 +27,14 @@ def wrong1():
global a
global b
"""
-compile_and_catch_warning(prog_text_1)
+compile_and_check(prog_text_1)
prog_text_2 = """
def wrong2():
print x
global x
"""
-compile_and_catch_warning(prog_text_2)
+compile_and_check(prog_text_2)
prog_text_3 = """
def wrong3():
@@ -36,10 +42,10 @@ def wrong3():
x = 2
global x
"""
-compile_and_catch_warning(prog_text_3)
+compile_and_check(prog_text_3)
prog_text_4 = """
global x
x = 2
"""
-compile_and_catch_warning(prog_text_4)
+compile_and_check(prog_text_4, 0)