[pypy-commit] pypy __debug__-optimize: update test to match lib-python

rlamy pypy.commits at gmail.com
Tue Aug 6 11:05:10 EDT 2019


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: __debug__-optimize
Changeset: r97075:e3c0c0d858a7
Date: 2019-08-06 15:21 +0100
http://bitbucket.org/pypy/pypy/changeset/e3c0c0d858a7/

Log:	update test to match lib-python

diff --git a/pypy/module/__builtin__/test/apptest_compile.py b/pypy/module/__builtin__/test/apptest_compile.py
--- a/pypy/module/__builtin__/test/apptest_compile.py
+++ b/pypy/module/__builtin__/test/apptest_compile.py
@@ -108,31 +108,32 @@
     try:
         assert False
     except AssertionError:
-        return (True, f.__doc__)
+        return (True, f.__doc__, __debug__)
     else:
-        return (False, f.__doc__)
+        return (False, f.__doc__, __debug__)
     '''
 
-    def f(): """doc"""
-    values = [(-1, __debug__, f.__doc__),
-                (0, True, 'doc'),
-                (1, False, 'doc'),
-                (2, False, None)]
+    def f():
+        """doc"""
 
-    for optval, debugval, docstring in values:
+    values = [(-1, __debug__, f.__doc__, __debug__),
+        (0, True, 'doc', True),
+        (1, False, 'doc', False),
+        (2, False, None, False)]
+
+    for optval, *expected in values:
         # test both direct compilation and compilation via AST
         codeobjs = []
-        codeobjs.append(
-                compile(codestr, "<test>", "exec", optimize=optval))
+        codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
         tree = ast.parse(codestr)
         codeobjs.append(compile(tree, "<test>", "exec", optimize=optval))
-
         for i, code in enumerate(codeobjs):
-            print(optval, debugval, docstring, i)
+            print(optval, *expected, i)
             ns = {}
             exec(code, ns)
             rv = ns['f']()
-            assert rv == (debugval, docstring)
+            print(rv)
+            assert rv == tuple(expected)
 
 def test_assert_remove():
     """Test removal of the asserts with optimize=1."""


More information about the pypy-commit mailing list