2001-03-01 01:48:06 +08:00
|
|
|
# Test various flavors of legal and illegal future statements
|
|
|
|
|
|
|
|
from test_support import unload
|
|
|
|
import re
|
|
|
|
|
|
|
|
rx = re.compile('\((\S+).py, line (\d+)')
|
|
|
|
|
|
|
|
def check_error_location(msg):
|
|
|
|
mo = rx.search(msg)
|
|
|
|
print "SyntaxError %s %s" % mo.group(1, 2)
|
|
|
|
|
|
|
|
# The first two tests should work
|
|
|
|
|
|
|
|
unload('test_future1')
|
|
|
|
import test_future1
|
|
|
|
|
|
|
|
unload('test_future2')
|
|
|
|
import test_future2
|
|
|
|
|
|
|
|
# The remaining tests should fail
|
|
|
|
try:
|
2001-04-18 09:19:28 +08:00
|
|
|
import badsyntax_future3
|
2001-03-01 01:48:06 +08:00
|
|
|
except SyntaxError, msg:
|
|
|
|
check_error_location(str(msg))
|
|
|
|
|
|
|
|
try:
|
2001-04-18 09:19:28 +08:00
|
|
|
import badsyntax_future4
|
2001-03-01 01:48:06 +08:00
|
|
|
except SyntaxError, msg:
|
|
|
|
check_error_location(str(msg))
|
|
|
|
|
|
|
|
try:
|
2001-04-18 09:19:28 +08:00
|
|
|
import badsyntax_future5
|
2001-03-01 01:48:06 +08:00
|
|
|
except SyntaxError, msg:
|
|
|
|
check_error_location(str(msg))
|
|
|
|
|
|
|
|
try:
|
2001-04-18 09:19:28 +08:00
|
|
|
import badsyntax_future6
|
2001-03-01 01:48:06 +08:00
|
|
|
except SyntaxError, msg:
|
|
|
|
check_error_location(str(msg))
|
|
|
|
|
|
|
|
try:
|
2001-04-18 09:19:28 +08:00
|
|
|
import badsyntax_future7
|
2001-03-01 01:48:06 +08:00
|
|
|
except SyntaxError, msg:
|
|
|
|
check_error_location(str(msg))
|