propogate current PYTHONPATH

This commit is contained in:
Benjamin Peterson 2011-12-19 12:02:07 -05:00
parent 03cb37b1eb
commit 268c051eba
1 changed files with 7 additions and 2 deletions

View File

@ -410,15 +410,20 @@ class TestInvocationVariants:
"*1 passed*" "*1 passed*"
]) ])
def join_pythonpath(what):
cur = py.std.os.environ.get('PYTHONPATH')
if cur:
return str(what) + ':' + cur
return what
empty_package = testdir.mkpydir("empty_package") empty_package = testdir.mkpydir("empty_package")
monkeypatch.setenv('PYTHONPATH', empty_package) monkeypatch.setenv('PYTHONPATH', join_pythonpath(empty_package))
result = testdir.runpytest("--pyargs", ".") result = testdir.runpytest("--pyargs", ".")
assert result.ret == 0 assert result.ret == 0
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*2 passed*" "*2 passed*"
]) ])
monkeypatch.setenv('PYTHONPATH', testdir) monkeypatch.setenv('PYTHONPATH', join_pythonpath(testdir))
path.join('test_hello.py').remove() path.join('test_hello.py').remove()
result = testdir.runpytest("--pyargs", "tpkg.test_hello") result = testdir.runpytest("--pyargs", "tpkg.test_hello")
assert result.ret != 0 assert result.ret != 0