summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-02-28 17:48:06 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-02-28 17:48:06 (GMT)
commit62e2c7e3dfffd8465a54b99fc6d3c2a60acab350 (patch)
treec65779760ccbdca9ec76deb901b94fd91e0908af /Lib/test
parentad3d3f2f3f19833f59fd7e9ec59e1714e0986e08 (diff)
downloadcpython-62e2c7e3dfffd8465a54b99fc6d3c2a60acab350.zip
cpython-62e2c7e3dfffd8465a54b99fc6d3c2a60acab350.tar.gz
cpython-62e2c7e3dfffd8465a54b99fc6d3c2a60acab350.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/output/test_future8
-rwxr-xr-xLib/test/regrtest.py7
-rw-r--r--Lib/test/test_future.py45
-rw-r--r--Lib/test/test_future1.py9
-rw-r--r--Lib/test/test_future2.py10
-rw-r--r--Lib/test/test_future3.py10
-rw-r--r--Lib/test/test_future4.py10
-rw-r--r--Lib/test/test_future5.py12
-rw-r--r--Lib/test/test_future6.py10
-rw-r--r--Lib/test/test_future7.py11
10 files changed, 132 insertions, 0 deletions
diff --git a/Lib/test/output/test_future b/Lib/test/output/test_future
new file mode 100644
index 0000000..5d7770a
--- /dev/null
+++ b/Lib/test/output/test_future
@@ -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
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 43e630e..f05f764 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -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):
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py
new file mode 100644
index 0000000..36a1346
--- /dev/null
+++ b/Lib/test/test_future.py
@@ -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))
+
diff --git a/Lib/test/test_future1.py b/Lib/test/test_future1.py
new file mode 100644
index 0000000..0589661
--- /dev/null
+++ b/Lib/test/test_future1.py
@@ -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)
diff --git a/Lib/test/test_future2.py b/Lib/test/test_future2.py
new file mode 100644
index 0000000..e3df0a6
--- /dev/null
+++ b/Lib/test/test_future2.py
@@ -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)
diff --git a/Lib/test/test_future3.py b/Lib/test/test_future3.py
new file mode 100644
index 0000000..166628c
--- /dev/null
+++ b/Lib/test/test_future3.py
@@ -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)
diff --git a/Lib/test/test_future4.py b/Lib/test/test_future4.py
new file mode 100644
index 0000000..805263b
--- /dev/null
+++ b/Lib/test/test_future4.py
@@ -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)
diff --git a/Lib/test/test_future5.py b/Lib/test/test_future5.py
new file mode 100644
index 0000000..1186208
--- /dev/null
+++ b/Lib/test/test_future5.py
@@ -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)
diff --git a/Lib/test/test_future6.py b/Lib/test/test_future6.py
new file mode 100644
index 0000000..35c1455
--- /dev/null
+++ b/Lib/test/test_future6.py
@@ -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)
diff --git a/Lib/test/test_future7.py b/Lib/test/test_future7.py
new file mode 100644
index 0000000..370372d
--- /dev/null
+++ b/Lib/test/test_future7.py
@@ -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)