summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2015-06-19 11:37:08 +0200
committerholger krekel <holger@merlinux.eu>2015-06-19 11:37:08 +0200
commit519dfc099f43747518187151164f9cfcc1ef09a6 (patch)
treef26e00d59befd3454fd9b8fd0cd395676f8fe27e
parent1d4d3b9433785bf397ef55c3f689a0b48a844c3f (diff)
downloadtox-519dfc099f43747518187151164f9cfcc1ef09a6.tar.gz
introduce a TOX_TESTENV_PASSENV setting which is honored
when constructing the set of environment variables for test environments.
-rw-r--r--CHANGELOG4
-rw-r--r--setup.py2
-rw-r--r--tests/test_config.py12
-rw-r--r--tox/__init__.py2
-rw-r--r--tox/config.py11
-rw-r--r--tox/session.py6
6 files changed, 32 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 66e1fee..3ae702c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,10 @@
- allow envlist to be a multi-line list, to intersperse comments
and have long envlist settings split more naturally. Thanks Andre Caron.
+- introduce a TOX_TESTENV_PASSENV setting which is honored
+ when constructing the set of environment variables for test environments.
+ Thanks Marc Abramowitz for pushing in this direction.
+
2.0.2
----------
diff --git a/setup.py b/setup.py
index a97020c..f297a9d 100644
--- a/setup.py
+++ b/setup.py
@@ -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.1.0.dev1',
+ version='2.1.0.dev2',
license='http://opensource.org/licenses/MIT',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
diff --git a/tests/test_config.py b/tests/test_config.py
index 248f1d6..8aa7abd 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -789,6 +789,18 @@ class TestConfigTestEnv:
assert "CB21" not in config.envconfigs["x2"].passenv
assert "BX23" not in config.envconfigs["x2"].passenv
+ def test_passenv_from_global_env(self, tmpdir, newconfig, monkeypatch):
+ monkeypatch.setenv("A1", "a1")
+ monkeypatch.setenv("A2", "a2")
+ monkeypatch.setenv("TOX_TESTENV_PASSENV", "A1")
+ config = newconfig("""
+ [testenv]
+ passenv = A2
+ """)
+ env = config.envconfigs["python"]
+ assert "A1" in env.passenv
+ assert "A2" in env.passenv
+
def test_changedir_override(self, tmpdir, newconfig):
config = newconfig("""
[testenv]
diff --git a/tox/__init__.py b/tox/__init__.py
index 3034588..e3872ec 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '2.1.0.dev1'
+__version__ = '2.1.0.dev2'
from .hookspecs import hookspec, hookimpl # noqa
diff --git a/tox/config.py b/tox/config.py
index 177bfcc..092de2a 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -295,9 +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.")
+ 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",
@@ -388,6 +388,11 @@ def tox_addoption(parser):
passenv = set(["PATH", "PIP_INDEX_URL", "LANG"])
+ # read in global passenv settings
+ p = os.environ.get("TOX_TESTENV_PASSENV", None)
+ if p is not None:
+ passenv.update(x for x in p.split() if x)
+
# we ensure that tmp directory settings are passed on
# we could also set it to the per-venv "envtmpdir"
# but this leads to very long paths when run with jenkins
diff --git a/tox/session.py b/tox/session.py
index 37d6b5c..b00465b 100644
--- a/tox/session.py
+++ b/tox/session.py
@@ -46,6 +46,12 @@ def show_help(config):
tw = py.io.TerminalWriter()
tw.write(config._parser._format_help())
tw.line()
+ tw.line("Environment variables", bold=True)
+ tw.line("TOXENV: comma separated list of environments "
+ "(overridable by '-e')")
+ tw.line("TOX_TESTENV_PASSENV: space-separated list of extra "
+ "environment variables to be passed into test command "
+ "environemnts")
def show_help_ini(config):