[pypy-commit] pypy ffi-backend: Fix for py.test -A.

arigo noreply at buildbot.pypy.org
Tue Aug 7 10:25:39 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r56622:4af2dc05568b
Date: 2012-08-07 08:24 +0000
http://bitbucket.org/pypy/pypy/changeset/4af2dc05568b/

Log:	Fix for py.test -A.

diff --git a/pypy/module/_cffi_backend/test/test_c.py b/pypy/module/_cffi_backend/test/test_c.py
--- a/pypy/module/_cffi_backend/test/test_c.py
+++ b/pypy/module/_cffi_backend/test/test_c.py
@@ -5,7 +5,7 @@
 """
 import py, sys, ctypes
 from pypy.tool.udir import udir
-from pypy.conftest import gettestobjspace
+from pypy.conftest import gettestobjspace, option
 from pypy.interpreter import gateway
 from pypy.module._cffi_backend.test import _backend_test_c
 from pypy.module._cffi_backend import Module
@@ -40,11 +40,21 @@
         cdll.gettestfunc.restype = ctypes.c_void_p
 
         def testfunc_for_test(space, w_num):
-            addr = cdll.gettestfunc(space.int_w(w_num))
+            if hasattr(space, 'int_w'):
+                w_num = space.int_w(w_num)
+            addr = cdll.gettestfunc(w_num)
             return space.wrap(addr)
 
-        w_func = space.wrap(gateway.interp2app(find_and_load_library_for_test))
-        w_testfunc = space.wrap(gateway.interp2app(testfunc_for_test))
+        if option.runappdirect:
+            def interp2app(func):
+                def run(*args):
+                    return func(space, *args)
+                return run
+        else:
+            interp2app = gateway.interp2app
+
+        w_func = space.wrap(interp2app(find_and_load_library_for_test))
+        w_testfunc = space.wrap(interp2app(testfunc_for_test))
         space.appexec([space.wrap(str(tmpdir)), w_func, w_testfunc,
                        space.wrap(sys.version[:3])],
         """(path, func, testfunc, underlying_version):


More information about the pypy-commit mailing list