summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rose <offby1@offby1.net>2011-04-30 09:09:29 -0600
committerChris Rose <offby1@offby1.net>2011-04-30 09:09:29 -0600
commit49f43dea65758d62308bea2e7e1708262bbcb622 (patch)
tree9da3b4d9f8b8464c48d3503aedda376261956a2a
parentc1e4d5ee4cfa16c58822f5ba03b53794de08775a (diff)
downloadtox-49f43dea65758d62308bea2e7e1708262bbcb622.tar.gz
When an environment value is provided by the session, _add_ it to the os.environ dict
-rw-r--r--tests/test_venv.py9
-rw-r--r--tox/_venv.py8
2 files changed, 13 insertions, 4 deletions
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 2c3a4b6..204d915 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -205,7 +205,7 @@ def test_install_error(newmocksession):
venv = mocksession.getenv('python')
venv.test()
mocksession.report.expect("error", "*not find*qwelkqw*")
-
+
def test_install_python3(tmpdir, newmocksession):
if not py.path.local.sysfind('python3.1'):
py.test.skip("needs python3.1")
@@ -338,7 +338,7 @@ class TestCreationConfig:
mocksession._clearmocks()
venv.update()
mocksession.report.expect("action", "recreating virtualenv*")
-
+
class TestVenvTest:
def test_patchPATH(self, newmocksession, monkeypatch):
@@ -371,7 +371,7 @@ class TestVenvTest:
assert 'PIP_RESPECT_VIRTUALENV' not in os.environ
os.environ['PIP_RESPECT_VIRTUALENV'] = "1"
-def test_session_environment_passed_to_pcall(mocksession, newconfig):
+def test_session_environment_added_to_pcall(mocksession, newconfig):
config = newconfig([], """
[testenv:python]
commands=%s -V
@@ -392,6 +392,9 @@ def test_session_environment_passed_to_pcall(mocksession, newconfig):
assert 'ENV_VAR' in env
assert env['ENV_VAR'] == 'value'
+ for e in os.environ:
+ assert e in env
+
def test_install_sdist_upgrade_mode(newmocksession):
mocksession = newmocksession([], "")
venv = mocksession.getenv('python')
diff --git a/tox/_venv.py b/tox/_venv.py
index 2ef6933..a723b79 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -232,9 +232,15 @@ class VirtualEnv(object):
self.session.make_emptydir(self.envconfig.envtmpdir)
cwd = self.envconfig.changedir
env = self.envconfig.environment
+ if env:
+ env_arg = os.environ.copy()
+ env_arg.update(env)
+ else:
+ env_arg = None
+
for argv in self.envconfig.commands:
try:
- self._pcall(argv, log=-1, cwd=cwd, env=env)
+ self._pcall(argv, log=-1, cwd=cwd, env=env_arg)
except tox.exception.InvocationError:
self.session.report.error(str(sys.exc_info()[1]))
return True