Armin Rigo  committed 9730bd3

Try harder to run the tests even if PYTHONPATH was not set and cffi not
installed. Tested with a "python build_ext -i" as well as with
a fresh "python install".

  • Participants
  • Parent commits 3643242

Comments (0)

Files changed (4)

 import py
+def _setup_path():
+    import os, sys
+    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
 from _cffi_backend import *
 from _cffi_backend import _testfunc, _get_types

File testing/

-import time
+import sys, time
+sys.path.insert(0, sys.argv[1])
 from cffi import FFI
 def _run_callback_in_thread():

File testing/

 def test_callback_in_thread():
     if sys.platform == 'win32':
         py.test.skip("pthread only")
-    import os, subprocess
+    import os, subprocess, imp
     arg = os.path.join(os.path.dirname(__file__), '')
-    g = subprocess.Popen([sys.executable, arg])
+    g = subprocess.Popen([sys.executable, arg,
+                          os.path.dirname(imp.find_module('cffi')[1])])
     result = g.wait()
     assert result == 0

File testing/

             site_packages = dirpath
     if site_packages:
-        for module in ('pycparser', 'ply'):
-            os.symlink(imp.find_module(module)[1],
-                       os.path.join(site_packages, module))
+        for module in ('cffi', '_cffi_backend', 'pycparser', 'ply'):
+            target = imp.find_module(module)[1]
+            os.symlink(target, os.path.join(site_packages,
+                                            os.path.basename(target)))
     return tmpdir
 SNIPPET_DIR = py.path.local(__file__).join('..', 'snippets')