[pypy-commit] pypy py3k: add the pypyroot to the appdirect sys.path so it can import from lib_pypy

pjenvey noreply at buildbot.pypy.org
Sat Jul 20 03:40:01 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r65501:fd721a7dc616
Date: 2013-07-19 18:38 -0700
http://bitbucket.org/pypy/pypy/changeset/fd721a7dc616/

Log:	add the pypyroot to the appdirect sys.path so it can import from
	lib_pypy

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
@@ -7,6 +7,7 @@
 # ...unless the -A option ('runappdirect') is passed.
 
 import py
+import os
 import sys, textwrap, types
 from pypy.interpreter.gateway import app2interp_temp
 from pypy.interpreter.error import OperationError
@@ -15,9 +16,11 @@
 from pypy.tool.pytest import appsupport
 from pypy.tool.pytest.objspace import gettestobjspace
 from rpython.tool.udir import udir
-from pypy.conftest import PyPyClassCollector
+from pypy.conftest import PyPyClassCollector, pypydir
 from inspect import getmro
 
+pypyroot = os.path.dirname(pypydir)
+
 RENAMED_USEMODULES = dict(
     _winreg='winreg',
     exceptions='builtins',
@@ -69,6 +72,7 @@
     helpers = r"""# -*- encoding: utf-8 -*-
 if 1:
     import sys
+    sys.path.append('%s')
 %s
     def skip(message):
         print(message)
@@ -161,7 +165,7 @@
     else:
         target_name = target_.__name__
     with pyfile.open('w') as f:
-        f.write(helpers % check_usemodules)
+        f.write(helpers % (pypyroot, check_usemodules))
         f.write('\n'.join(defs))
         f.write('def %s():\n' % target_name)
         f.write('\n'.join(source))


More information about the pypy-commit mailing list