[Python-checkins] CVS: python/dist/src/Lib/test test_global.py,1.4,1.5
Tim Peters
tim_one@users.sourceforge.net
Thu, 01 Mar 2001 17:48:18 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv6515/python/dist/src/Lib/test
Modified Files:
test_global.py
Log Message:
test_global was broken by some recent checkin. Repairing.
Index: test_global.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_global.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** test_global.py 2001/02/28 23:49:19 1.4
--- test_global.py 2001/03/02 01:48:16 1.5
***************
*** 1,3 ****
! """Verify that warnings are issued for global statements following use"""
from test_support import check_syntax
--- 1,3 ----
! """Verify that warnings are issued for global statements following use."""
from test_support import check_syntax
***************
*** 7,17 ****
warnings.filterwarnings("error", module="<test code>")
! def compile_and_catch_warning(text):
try:
compile(text, "<test code>", "exec")
except SyntaxError, msg:
! print "got SyntaxError as expected"
else:
! print "expected SyntaxError"
prog_text_1 = """
--- 7,23 ----
warnings.filterwarnings("error", module="<test code>")
! def compile_and_check(text, should_fail=1):
try:
compile(text, "<test code>", "exec")
except SyntaxError, msg:
! if should_fail:
! print "got SyntaxError as expected"
! else:
! print "raised unexpected SyntaxError:", text
else:
! if should_fail:
! print "should have raised SyntaxError:", text
! else:
! print "as expected, no SyntaxError"
prog_text_1 = """
***************
*** 22,26 ****
global b
"""
! compile_and_catch_warning(prog_text_1)
prog_text_2 = """
--- 28,32 ----
global b
"""
! compile_and_check(prog_text_1)
prog_text_2 = """
***************
*** 29,33 ****
global x
"""
! compile_and_catch_warning(prog_text_2)
prog_text_3 = """
--- 35,39 ----
global x
"""
! compile_and_check(prog_text_2)
prog_text_3 = """
***************
*** 37,41 ****
global x
"""
! compile_and_catch_warning(prog_text_3)
prog_text_4 = """
--- 43,47 ----
global x
"""
! compile_and_check(prog_text_3)
prog_text_4 = """
***************
*** 43,45 ****
x = 2
"""
! compile_and_catch_warning(prog_text_4)
--- 49,51 ----
x = 2
"""
! compile_and_check(prog_text_4, 0)