Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r51834:a8eb581e9e9a
Date: 2012-01-26 17:58 +0100
http://bitbucket.org/pypy/pypy/changeset/a8eb581e9e9a/
Log: extend these test to make sure that the valid snippets are actually
valid with cpython3. So far it expects to find the python3
executable in the path
diff --git a/pypy/interpreter/test/test_syntax.py
b/pypy/interpreter/test/test_syntax.py
--- a/pypy/interpreter/test/test_syntax.py
+++ b/pypy/interpreter/test/test_syntax.py
@@ -1,4 +1,5 @@
import py
+import commands
from pypy.conftest import gettestobjspace
def splitcases(s):
@@ -126,9 +127,10 @@
for i in range(len(VALID)):
- exec """def test_valid_%d(space):
+ exec """def test_valid_%d(space, tmpdir):
+ checkvalid_cpython(tmpdir, %d, %r)
checkvalid(space, %r)
-""" % (i, VALID[i])
+""" % (i, i, VALID[i], VALID[i])
for i in range(len(INVALID)):
exec """def test_invalid_%d(space):
@@ -136,6 +138,27 @@
""" % (i, INVALID[i])
+def checkvalid_cpython(tmpdir, i, s):
+ src = '''
+try:
+ exec("""%s
+""")
+except SyntaxError as e:
+ print(e)
+ raise SystemExit(1)
+else:
+ print('OK')
+''' % s
+ pyfile = tmpdir.join('checkvalid_%d.py' % i)
+ pyfile.write(src)
+ res = commands.getoutput('python3 "%s"' % pyfile)
+ if res != 'OK':
+ print s
+ print
+ print res
+ assert False, 'checkvalid_cpython failed'
+
+
def checkvalid(space, s):
try:
space.call_function(space.builtin.get('compile'),
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit