diff options
-rw-r--r-- | CHANGELOG | 6 | ||||
-rw-r--r-- | doc/config.txt | 18 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/test_venv.py | 6 | ||||
-rw-r--r-- | tox/__init__.py | 2 | ||||
-rw-r--r-- | tox/config.py | 7 | ||||
-rw-r--r-- | tox/venv.py | 18 |
7 files changed, 40 insertions, 19 deletions
@@ -1,3 +1,9 @@ +2.1.0 +---------- + +- fix issue258, fix issue248, fix issue253: for non-test commands + (installation, venv creation) we pass in the full invocation environment. + 2.0.2 ---------- diff --git a/doc/config.txt b/doc/config.txt index 5a335f9..c392289 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -195,14 +195,16 @@ Complete list of settings that you can put into ``testenv*`` sections: A list of wildcard environment variable names which shall be copied from the tox invocation environment to the test - environment. If a specified environment variable doesn't exist in the tox - invocation environment it is ignored. You can use ``*`` and ``?`` to - match multiple environment variables with one name. - - Note that the ``PATH`` and ``PIP_INDEX_URL`` variables are unconditionally - passed down and on Windows ``SYSTEMROOT``, ``PATHEXT``, ``TEMP`` and ``TMP`` - will be passed down as well whereas on unix ``TMPDIR`` will be passed down. - You can override these variables with the ``setenv`` option. + environment when executing test commands. If a specified environment + variable doesn't exist in the tox invocation environment it is ignored. + You can use ``*`` and ``?`` to match multiple environment variables with + one name. + + Note that the ``PATH``, ``LANG`` and ``PIP_INDEX_URL`` variables are + unconditionally passed down and on Windows ``SYSTEMROOT``, ``PATHEXT``, + ``TEMP`` and ``TMP`` will be passed down as well whereas on unix + ``TMPDIR`` will be passed down. You can override these variables + with the ``setenv`` option. .. confval:: recreate=True|False(default) @@ -48,7 +48,7 @@ def main(): description='virtualenv-based automation of test activities', long_description=open("README.rst").read(), url='http://tox.testrun.org/', - version='2.0.2', + version='2.1.0.dev1', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff --git a/tests/test_venv.py b/tests/test_venv.py index d00b655..37b0f50 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -510,6 +510,7 @@ class TestVenvTest: def test_env_variables_added_to_pcall(tmpdir, mocksession, newconfig, monkeypatch): pkg = tmpdir.ensure("package.tar.gz") monkeypatch.setenv("X123", "123") + monkeypatch.setenv("YY", "456") config = newconfig([], """ [testenv:python] commands=python -V @@ -533,9 +534,12 @@ def test_env_variables_added_to_pcall(tmpdir, mocksession, newconfig, monkeypatc assert env['ENV_VAR'] == 'value' assert env['VIRTUAL_ENV'] == str(venv.path) assert env['X123'] == "123" + # all env variables are passed for installation + assert l[0].env["YY"] == "456" + assert "YY" not in l[1].env assert set(["ENV_VAR", "VIRTUAL_ENV", "PYTHONHASHSEED", "X123", "PATH"])\ - .issubset(env) + .issubset(l[1].env) # for e in os.environ: # assert e in env diff --git a/tox/__init__.py b/tox/__init__.py index 2eccc2e..3034588 100644 --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '2.0.2' +__version__ = '2.1.0.dev1' from .hookspecs import hookspec, hookimpl # noqa diff --git a/tox/config.py b/tox/config.py index 52e0dbc..9026f28 100644 --- a/tox/config.py +++ b/tox/config.py @@ -409,8 +409,11 @@ def tox_addoption(parser): parser.add_testenv_attribute( name="passenv", type="space-separated-list", postprocess=passenv, - help="environment variables names which shall be passed " - "from tox invocation to test environment when executing commands.") + help="environment variables needed during executing test commands " + "(taken from invocation environment). Not that tox always " + "passes in some basic environment variables which are needed for " + "basic functioning of the Python interpreter. See --showconfig " + "for the resulting passenv setting.") parser.add_testenv_attribute( name="whitelist_externals", type="line-list", diff --git a/tox/venv.py b/tox/venv.py index eb2fadc..2f5d583 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -317,16 +317,22 @@ class VirtualEnv(object): action=action, extraenv=extraenv) def _getenv(self, extraenv={}): - env = {} - for envname in self.envconfig.passenv: - if envname in os.environ: - env[envname] = os.environ[envname] + if extraenv is None: + # for executing tests + env = {} + for envname in self.envconfig.passenv: + if envname in os.environ: + env[envname] = os.environ[envname] + else: + # for executing install commands + env = os.environ.copy() env.update(self.envconfig.setenv) env['VIRTUAL_ENV'] = str(self.path) + if extraenv is not None: + env.update(extraenv) - env.update(extraenv) return env def test(self, redirect=False): @@ -357,7 +363,7 @@ class VirtualEnv(object): try: self._pcall(argv, cwd=cwd, action=action, redirect=redirect, - ignore_ret=ignore_ret) + ignore_ret=ignore_ret, extraenv=None) except tox.exception.InvocationError as err: self.session.report.error(str(err)) self.status = "commands failed" |