summaryrefslogtreecommitdiff
path: root/tox
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2015-06-18 16:07:14 +0200
committerholger krekel <holger@merlinux.eu>2015-06-18 16:07:14 +0200
commit8c7dbd8d2e1f03b977b0a716b0936fff5f08e37b (patch)
tree72c7045bf93728fc63914487dc8e8def705825cb /tox
parent8602c192146a66b029919619ca32e2465546e6e0 (diff)
downloadtox-8c7dbd8d2e1f03b977b0a716b0936fff5f08e37b.tar.gz
cleanup internal env variable code a bit
Diffstat (limited to 'tox')
-rw-r--r--tox/config.py8
-rw-r--r--tox/venv.py33
2 files changed, 16 insertions, 25 deletions
diff --git a/tox/config.py b/tox/config.py
index 609208c..5345ce3 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -295,11 +295,9 @@ def tox_addoption(parser):
dest="recreate",
help="force recreation of virtual environments")
parser.add_argument("--result-json", action="store",
- dest="resultjson", metavar="PATH",
- help="write a json file with detailed information about "
- "all commands and results involved. This will turn off "
- "pass-through output from running test commands which is "
- "instead captured into the json result file.")
+ dest="resultjson", metavar="PATH",
+ help="write a json file with detailed information about "
+ "all commands and results involved.")
# We choose 1 to 4294967295 because it is the range of PYTHONHASHSEED.
parser.add_argument("--hashseed", action="store",
diff --git a/tox/venv.py b/tox/venv.py
index d3e4e70..6a64951 100644
--- a/tox/venv.py
+++ b/tox/venv.py
@@ -267,12 +267,11 @@ class VirtualEnv(object):
if '{opts}' in argv:
i = argv.index('{opts}')
argv[i:i + 1] = list(options)
+
for x in ('PIP_RESPECT_VIRTUALENV', 'PIP_REQUIRE_VIRTUALENV',
'__PYVENV_LAUNCHER__'):
- try:
- del os.environ[x]
- except KeyError:
- pass
+ os.environ.pop(x, None)
+
old_stdout = sys.stdout
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
self._pcall(argv, cwd=self.envconfig.config.toxinidir, action=action)
@@ -304,8 +303,8 @@ class VirtualEnv(object):
self.run_install_command(packages=packages, options=options,
action=action)
- def _getenv(self, extraenv={}):
- if extraenv is None:
+ def _getenv(self, testcommand=False):
+ if testcommand:
# for executing tests we construct a clean environment
env = {}
for envname in self.envconfig.passenv:
@@ -320,9 +319,6 @@ class VirtualEnv(object):
env.update(self.envconfig.setenv)
env['VIRTUAL_ENV'] = str(self.path)
- if extraenv is not None:
- env.update(extraenv)
-
return env
def test(self, redirect=False):
@@ -331,7 +327,7 @@ class VirtualEnv(object):
self.status = 0
self.session.make_emptydir(self.envconfig.envtmpdir)
cwd = self.envconfig.changedir
- env = self._getenv()
+ env = self._getenv(testcommand=True)
# Display PYTHONHASHSEED to assist with reproducibility.
action.setactivity("runtests", "PYTHONHASHSEED=%r" % env.get('PYTHONHASHSEED'))
for i, argv in enumerate(self.envconfig.commands):
@@ -353,7 +349,7 @@ class VirtualEnv(object):
try:
self._pcall(argv, cwd=cwd, action=action, redirect=redirect,
- ignore_ret=ignore_ret, extraenv=None)
+ ignore_ret=ignore_ret, testcommand=True)
except tox.exception.InvocationError as err:
self.session.report.error(str(err))
self.status = "commands failed"
@@ -364,20 +360,18 @@ class VirtualEnv(object):
self.session.report.error(self.status)
raise
- def _pcall(self, args, venv=True, cwd=None, extraenv={},
+ def _pcall(self, args, cwd, venv=True, testcommand=False,
action=None, redirect=True, ignore_ret=False):
for name in ("VIRTUALENV_PYTHON", "PYTHONDONTWRITEBYTECODE"):
- try:
- del os.environ[name]
- except KeyError:
- pass
- assert cwd
+ os.environ.pop(name, None)
+
cwd.ensure(dir=1)
old = self.patchPATH()
try:
args[0] = self.getcommandpath(args[0], venv, cwd)
- env = self._getenv(extraenv)
- return action.popen(args, cwd=cwd, env=env, redirect=redirect, ignore_ret=ignore_ret)
+ env = self._getenv(testcommand=testcommand)
+ return action.popen(args, cwd=cwd, env=env,
+ redirect=redirect, ignore_ret=ignore_ret)
finally:
os.environ['PATH'] = old
@@ -394,4 +388,3 @@ def getdigest(path):
if not path.check(file=1):
return "0" * 32
return path.computehash()
-