Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: f5069b2f62ee8d7beb6b56d0ce38a5b1e8b01f8d authored by cvs2svn on 14 October 2002, 20:11:50 UTC
This commit was manufactured by cvs2svn to create tag 'r222'.
Tip revision: f5069b2
test_future.py
# 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

unload('test_future3')
import test_future3

# The remaining tests should fail
try:
    import badsyntax_future3
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import badsyntax_future4
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import badsyntax_future5
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import badsyntax_future6
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import badsyntax_future7
except SyntaxError, msg:
    check_error_location(str(msg))
back to top