[pypy-svn] r73489 - pypy/branch/decouple-host-opcodes/pypy/interpreter/astcompiler/test

antoine at codespeak.net antoine at codespeak.net
Wed Apr 7 02:15:33 CEST 2010


Author: antoine
Date: Wed Apr  7 02:15:31 2010
New Revision: 73489

Modified:
   pypy/branch/decouple-host-opcodes/pypy/interpreter/astcompiler/test/test_compiler.py
Log:
More test fixes for 2.7



Modified: pypy/branch/decouple-host-opcodes/pypy/interpreter/astcompiler/test/test_compiler.py
==============================================================================
--- pypy/branch/decouple-host-opcodes/pypy/interpreter/astcompiler/test/test_compiler.py	(original)
+++ pypy/branch/decouple-host-opcodes/pypy/interpreter/astcompiler/test/test_compiler.py	Wed Apr  7 02:15:31 2010
@@ -22,11 +22,15 @@
     """
 
     def run(self, source):
+        import sys
         source = str(py.code.Source(source))
         space = self.space
         code = compile_with_astcompiler(source, 'exec', space)
-        print
-        code.dump()
+        # 2.7 bytecode is too different, the standard `dis` module crashes
+        # when trying to display pypy (2.5-like) bytecode.
+        if sys.version_info < (2, 7):
+            print
+            code.dump()
         w_dict = space.newdict()
         code.exec_code(space, w_dict, w_dict)
         return w_dict
@@ -39,7 +43,12 @@
         pyco_expr = PyCode._from_code(space, co_expr)
         w_res = pyco_expr.exec_code(space, w_dict, w_dict)
         res = space.str_w(space.repr(w_res))
-        assert res == repr(expected)
+        if not isinstance(expected, float):
+            assert res == repr(expected)
+        else:
+            # Float representation can vary a bit between interpreter
+            # versions, compare the numbers instead.
+            assert eval(res) == expected
 
     def simple_test(self, source, evalexpr, expected):
         w_g = self.run(source)



More information about the Pypy-commit mailing list