[pypy-commit] pypy py3k: check for invalid syntax also on top of cpython3

antocuni noreply at buildbot.pypy.org
Fri Jan 27 00:31:40 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r51835:64a00c269dce
Date: 2012-01-27 00:02 +0100
http://bitbucket.org/pypy/pypy/changeset/64a00c269dce/

Log:	check for invalid syntax also on top of cpython3

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
@@ -133,12 +133,12 @@
 """ % (i, i, VALID[i], VALID[i])
 
 for i in range(len(INVALID)):
-    exec """def test_invalid_%d(space):
+    exec """def test_invalid_%d(space, tmpdir):
+                checkinvalid_cpython(tmpdir, %d, %r)
                 checkinvalid(space, %r)
-""" % (i, INVALID[i])
+""" % (i, i, INVALID[i], INVALID[i])
 
-
-def checkvalid_cpython(tmpdir, i, s):
+def checksyntax_cpython(tmpdir, i, s):
     src = '''
 try:
     exec("""%s
@@ -152,12 +152,24 @@
     pyfile = tmpdir.join('checkvalid_%d.py' % i)
     pyfile.write(src)
     res = commands.getoutput('python3 "%s"' % pyfile)
+    return res
+
+def checkvalid_cpython(tmpdir, i, s):
+    res = checksyntax_cpython(tmpdir, i, s)
     if res != 'OK':
         print s
         print
         print res
         assert False, 'checkvalid_cpython failed'
 
+def checkinvalid_cpython(tmpdir, i, s):
+    res = checksyntax_cpython(tmpdir, i, s)
+    if res == 'OK':
+        print s
+        print
+        print res
+        assert False, 'checkinvalid_cpython failed, did not raise SyntaxError'
+
 
 def checkvalid(space, s):
     try:


More information about the pypy-commit mailing list