Add regression test for future statements. This adds eight files, but
seven are not tests in their own right; these files are mentioned in regrtest.
This commit is contained in:
parent
ad3d3f2f3f
commit
62e2c7e3df
8
Lib/test/output/test_future
Normal file
8
Lib/test/output/test_future
Normal file
@ -0,0 +1,8 @@
|
||||
test_future
|
||||
6
|
||||
6
|
||||
SyntaxError test_future3 3
|
||||
SyntaxError test_future4 3
|
||||
SyntaxError test_future5 4
|
||||
SyntaxError test_future6 3
|
||||
SyntaxError test_future7 3
|
@ -197,6 +197,13 @@ NOTTESTS = [
|
||||
'test_support',
|
||||
'test_b1',
|
||||
'test_b2',
|
||||
'test_future1',
|
||||
'test_future2',
|
||||
'test_future3',
|
||||
'test_future4',
|
||||
'test_future5',
|
||||
'test_future6',
|
||||
'test_future7',
|
||||
]
|
||||
|
||||
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
|
||||
|
45
Lib/test/test_future.py
Normal file
45
Lib/test/test_future.py
Normal file
@ -0,0 +1,45 @@
|
||||
# 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:
|
||||
import test_future3
|
||||
except SyntaxError, msg:
|
||||
check_error_location(str(msg))
|
||||
|
||||
try:
|
||||
import test_future4
|
||||
except SyntaxError, msg:
|
||||
check_error_location(str(msg))
|
||||
|
||||
try:
|
||||
import test_future5
|
||||
except SyntaxError, msg:
|
||||
check_error_location(str(msg))
|
||||
|
||||
try:
|
||||
import test_future6
|
||||
except SyntaxError, msg:
|
||||
check_error_location(str(msg))
|
||||
|
||||
try:
|
||||
import test_future7
|
||||
except SyntaxError, msg:
|
||||
check_error_location(str(msg))
|
||||
|
9
Lib/test/test_future1.py
Normal file
9
Lib/test/test_future1.py
Normal file
@ -0,0 +1,9 @@
|
||||
"""This is a test"""
|
||||
from __future__ import nested_scopes
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
10
Lib/test/test_future2.py
Normal file
10
Lib/test/test_future2.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""This is a test"""
|
||||
|
||||
from __future__ import nested_scopes; import string
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
10
Lib/test/test_future3.py
Normal file
10
Lib/test/test_future3.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""This is a test"""
|
||||
from __future__ import nested_scopes
|
||||
from __future__ import rested_snopes
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
10
Lib/test/test_future4.py
Normal file
10
Lib/test/test_future4.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""This is a test"""
|
||||
import __future__
|
||||
from __future__ import nested_scopes
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
12
Lib/test/test_future5.py
Normal file
12
Lib/test/test_future5.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""This is a test"""
|
||||
from __future__ import nested_scopes
|
||||
import foo
|
||||
from __future__ import nested_scopes
|
||||
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
10
Lib/test/test_future6.py
Normal file
10
Lib/test/test_future6.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""This is a test"""
|
||||
"this isn't a doc string"
|
||||
from __future__ import nested_scopes
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
11
Lib/test/test_future7.py
Normal file
11
Lib/test/test_future7.py
Normal file
@ -0,0 +1,11 @@
|
||||
"""This is a test"""
|
||||
|
||||
from __future__ import nested_scopes; import string; from __future__ import \
|
||||
nested_scopes
|
||||
|
||||
def f(x):
|
||||
def g(y):
|
||||
return x + y
|
||||
return g
|
||||
|
||||
print f(2)(4)
|
Loading…
x
Reference in New Issue
Block a user