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

Skip to content

Commit 62e2c7e

Browse files
committed
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.
1 parent ad3d3f2 commit 62e2c7e

10 files changed

Lines changed: 132 additions & 0 deletions

File tree

Lib/test/output/test_future

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
test_future
2+
6
3+
6
4+
SyntaxError test_future3 3
5+
SyntaxError test_future4 3
6+
SyntaxError test_future5 4
7+
SyntaxError test_future6 3
8+
SyntaxError test_future7 3

Lib/test/regrtest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
197197
'test_support',
198198
'test_b1',
199199
'test_b2',
200+
'test_future1',
201+
'test_future2',
202+
'test_future3',
203+
'test_future4',
204+
'test_future5',
205+
'test_future6',
206+
'test_future7',
200207
]
201208

202209
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):

Lib/test/test_future.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Test various flavors of legal and illegal future statements
2+
3+
from test_support import unload
4+
import re
5+
6+
rx = re.compile('\((\S+).py, line (\d+)')
7+
8+
def check_error_location(msg):
9+
mo = rx.search(msg)
10+
print "SyntaxError %s %s" % mo.group(1, 2)
11+
12+
# The first two tests should work
13+
14+
unload('test_future1')
15+
import test_future1
16+
17+
unload('test_future2')
18+
import test_future2
19+
20+
# The remaining tests should fail
21+
try:
22+
import test_future3
23+
except SyntaxError, msg:
24+
check_error_location(str(msg))
25+
26+
try:
27+
import test_future4
28+
except SyntaxError, msg:
29+
check_error_location(str(msg))
30+
31+
try:
32+
import test_future5
33+
except SyntaxError, msg:
34+
check_error_location(str(msg))
35+
36+
try:
37+
import test_future6
38+
except SyntaxError, msg:
39+
check_error_location(str(msg))
40+
41+
try:
42+
import test_future7
43+
except SyntaxError, msg:
44+
check_error_location(str(msg))
45+

Lib/test/test_future1.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""This is a test"""
2+
from __future__ import nested_scopes
3+
4+
def f(x):
5+
def g(y):
6+
return x + y
7+
return g
8+
9+
print f(2)(4)

Lib/test/test_future2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""This is a test"""
2+
3+
from __future__ import nested_scopes; import string
4+
5+
def f(x):
6+
def g(y):
7+
return x + y
8+
return g
9+
10+
print f(2)(4)

Lib/test/test_future3.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""This is a test"""
2+
from __future__ import nested_scopes
3+
from __future__ import rested_snopes
4+
5+
def f(x):
6+
def g(y):
7+
return x + y
8+
return g
9+
10+
print f(2)(4)

Lib/test/test_future4.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""This is a test"""
2+
import __future__
3+
from __future__ import nested_scopes
4+
5+
def f(x):
6+
def g(y):
7+
return x + y
8+
return g
9+
10+
print f(2)(4)

Lib/test/test_future5.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""This is a test"""
2+
from __future__ import nested_scopes
3+
import foo
4+
from __future__ import nested_scopes
5+
6+
7+
def f(x):
8+
def g(y):
9+
return x + y
10+
return g
11+
12+
print f(2)(4)

Lib/test/test_future6.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""This is a test"""
2+
"this isn't a doc string"
3+
from __future__ import nested_scopes
4+
5+
def f(x):
6+
def g(y):
7+
return x + y
8+
return g
9+
10+
print f(2)(4)

Lib/test/test_future7.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""This is a test"""
2+
3+
from __future__ import nested_scopes; import string; from __future__ import \
4+
nested_scopes
5+
6+
def f(x):
7+
def g(y):
8+
return x + y
9+
return g
10+
11+
print f(2)(4)

0 commit comments

Comments
 (0)