[pypy-commit] pypy py3k-test-cpyext: Try to run some cpyext tests with -A

rlamy pypy.commits at gmail.com
Sat Oct 1 22:57:48 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k-test-cpyext
Changeset: r87511:243ced1b2519
Date: 2016-10-02 01:06 +0100
http://bitbucket.org/pypy/pypy/changeset/243ced1b2519/

Log:	Try to run some cpyext tests with -A

diff --git a/pypy/module/cpyext/test/conftest.py b/pypy/module/cpyext/test/conftest.py
--- a/pypy/module/cpyext/test/conftest.py
+++ b/pypy/module/cpyext/test/conftest.py
@@ -13,8 +13,6 @@
     space.getbuiltinmodule("time")
 
 def pytest_ignore_collect(path, config):
-    if config.option.runappdirect:
-        return True # "cannot be run by py.test -A"
     # ensure additional functions are registered
     import pypy.module.cpyext.test.test_cpyext
     return False
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -83,7 +83,7 @@
 
 class LeakCheckingTest(object):
     """Base class for all cpyext tests."""
-    spaceconfig = dict(usemodules=['cpyext', 'thread', '_rawffi', 'array',
+    spaceconfig = dict(usemodules=['cpyext', 'thread', 'struct', 'array',
                                    'itertools', 'time', 'binascii',
                                    ])
 
@@ -231,6 +231,15 @@
             cls.w_debug_collect = space.wrap(interp2app(debug_collect))
         else:
             cls.sys_info = get_sys_info_app()
+            def w_import_module(self, name, init=None, body='', filename=None,
+                    include_dirs=None, PY_SSIZE_T_CLEAN=False):
+                from extbuild import get_sys_info_app
+                sys_info = get_sys_info_app()
+                return sys_info.import_module(
+                    name, init=init, body=body, filename=filename,
+                    include_dirs=include_dirs,
+                    PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)
+            cls.w_import_module = w_import_module
 
     def record_imported_module(self, name):
         """
diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -172,8 +172,11 @@
         f.write('def %s():\n' % target_name)
         f.write('\n'.join(source))
         f.write("\n%s()\n" % target_name)
+    helper_dir = os.path.join(pypydir, 'tool', 'cpyext')
+    env = os.environ.copy()
+    env['PYTHONPATH'] = helper_dir
     res, stdout, stderr = runsubprocess.run_subprocess(
-        python_, [str(pyfile)])
+        python_, [str(pyfile)], env=env)
     print pyfile.read()
     print >> sys.stdout, stdout
     print >> sys.stderr, stderr


More information about the pypy-commit mailing list