Commit 336d8ca7 authored by Stefan Behnel's avatar Stefan Behnel Committed by GitHub

Merge pull request #2674 from jdemeyer/master

Fix reimport_from_subinterpreter test when PYTHONPATH is set
parents cc02495d d46b06fc
...@@ -1734,7 +1734,10 @@ class EndToEndTest(unittest.TestCase): ...@@ -1734,7 +1734,10 @@ class EndToEndTest(unittest.TestCase):
.replace("PYTHON", sys.executable)) .replace("PYTHON", sys.executable))
old_path = os.environ.get('PYTHONPATH') old_path = os.environ.get('PYTHONPATH')
env = dict(os.environ) env = dict(os.environ)
env['PYTHONPATH'] = self.cython_syspath + os.pathsep + (old_path or '') new_path = self.cython_syspath
if old_path:
new_path = new_path + os.pathsep + old_path
env['PYTHONPATH'] = new_path
cmd = [] cmd = []
out = [] out = []
err = [] err = []
......
...@@ -59,11 +59,14 @@ def run_sub(): ...@@ -59,11 +59,14 @@ def run_sub():
assert 0 == run_in_subinterpreter(b'1+1') assert 0 == run_in_subinterpreter(b'1+1')
assert 0 == run_in_subinterpreter(b'2+2') assert 0 == run_in_subinterpreter(b'2+2')
assert 0 == run_in_subinterpreter(b'import package') # The subinterpreter does not add the current working directory to
assert 0 == run_in_subinterpreter(b'import package') # sys.path, so we need to add it manually.
pre = b'import sys; sys.path.insert(0, "."); '
assert 0 == run_in_subinterpreter(pre + b'import package')
assert 0 == run_in_subinterpreter(pre + b'import package')
import sys import sys
result = run_in_subinterpreter(b'import package.subtest') result = run_in_subinterpreter(pre + b'import package.subtest')
if not MAIN_HAS_IMPORTED: if not MAIN_HAS_IMPORTED:
assert result == 0, result # imports only in subinterpreters are ok assert result == 0, result # imports only in subinterpreters are ok
elif sys.version_info >= (3, 5): elif sys.version_info >= (3, 5):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment