Skip to content

Commit

Permalink
python path optionally remove
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat committed Jun 25, 2018
1 parent 3896fbb commit 245bf9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,15 @@ def test(self, redirect=False):
raise

def _pcall(
self, args, cwd, venv=True, testcommand=False, action=None, redirect=True, ignore_ret=False
self,
args,
cwd,
venv=True,
testcommand=False,
action=None,
redirect=True,
ignore_ret=False,
no_python_path=False,
):
os.environ.pop("VIRTUALENV_PYTHON", None)

Expand All @@ -414,7 +422,8 @@ def _pcall(
env = self._getenv(testcommand=testcommand)
bindir = str(self.envconfig.envbindir)
env["PATH"] = p = os.pathsep.join([bindir, os.environ["PATH"]])
env.pop("PYTHONPATH", None)
if no_python_path:
env.pop("PYTHONPATH", None)
self.session.report.verbosity2("setting PATH={}".format(p))
return action.popen(args, cwd=cwd, env=env, redirect=redirect, ignore_ret=ignore_ret)

Expand Down Expand Up @@ -488,7 +497,10 @@ def tox_runtest(venv, redirect):
def tox_runenvreport(venv, action):
# write out version dependency information
args = venv.envconfig.list_dependencies_command
output = venv._pcall(args, cwd=venv.envconfig.config.toxinidir, action=action)
# we clear the PYTHONPATH to allow reporting packages outside of this environment
output = venv._pcall(
args, cwd=venv.envconfig.config.toxinidir, action=action, no_python_path=True
)
# the output contains a mime-header, skip it
output = output.split("\n\n")[-1]
packages = output.strip().split("\n")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_package_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_pyproject_toml_with_setuptools_scm(initproj, cmd):
[testenv]
passenv = PYTHONPATH
commands = python -c 'import demo; print(demo.__version__, end="")'
commands = python -c 'from __future__ import print_function; import demo; print(demo.__version__, end="")'
""",
},
)
Expand All @@ -145,7 +145,7 @@ def test_pyproject_toml_with_setuptools_scm(initproj, cmd):
py inst: {}
py installed: demo==0.1
py runtests: PYTHONHASHSEED='{}'
py runtests: commands[0] | python -c 'import demo; print(demo.__version__, end="")'
py runtests: commands[0] | python -c 'from __future__ import print_function; import demo; print(demo.__version__, end="")'
0.1___________________________________ summary {}___________________________________
py: commands succeeded
congratulations :)
Expand Down

0 comments on commit 245bf9e

Please sign in to comment.