Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc35de4

Browse files
committed
test_global was broken by some recent checkin. Repairing.
1 parent 7a25765 commit fc35de4

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

Lib/test/output/test_global

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ test_global
22
got SyntaxError as expected
33
got SyntaxError as expected
44
got SyntaxError as expected
5-
got SyntaxError as expected
5+
as expected, no SyntaxError

Lib/test/test_global.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
"""Verify that warnings are issued for global statements following use"""
1+
"""Verify that warnings are issued for global statements following use."""
22

33
from test_support import check_syntax
44

55
import warnings
66

77
warnings.filterwarnings("error", module="<test code>")
88

9-
def compile_and_catch_warning(text):
9+
def compile_and_check(text, should_fail=1):
1010
try:
1111
compile(text, "<test code>", "exec")
1212
except SyntaxError, msg:
13-
print "got SyntaxError as expected"
13+
if should_fail:
14+
print "got SyntaxError as expected"
15+
else:
16+
print "raised unexpected SyntaxError:", text
1417
else:
15-
print "expected SyntaxError"
18+
if should_fail:
19+
print "should have raised SyntaxError:", text
20+
else:
21+
print "as expected, no SyntaxError"
1622

1723
prog_text_1 = """
1824
def wrong1():
@@ -21,25 +27,25 @@ def wrong1():
2127
global a
2228
global b
2329
"""
24-
compile_and_catch_warning(prog_text_1)
30+
compile_and_check(prog_text_1)
2531

2632
prog_text_2 = """
2733
def wrong2():
2834
print x
2935
global x
3036
"""
31-
compile_and_catch_warning(prog_text_2)
37+
compile_and_check(prog_text_2)
3238

3339
prog_text_3 = """
3440
def wrong3():
3541
print x
3642
x = 2
3743
global x
3844
"""
39-
compile_and_catch_warning(prog_text_3)
45+
compile_and_check(prog_text_3)
4046

4147
prog_text_4 = """
4248
global x
4349
x = 2
4450
"""
45-
compile_and_catch_warning(prog_text_4)
51+
compile_and_check(prog_text_4, 0)

0 commit comments

Comments
 (0)