summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Mazzucco <pietranera@gmail.com>2015-06-18 22:56:38 +0100
committerStefano Mazzucco <pietranera@gmail.com>2015-06-18 22:56:38 +0100
commitc779525b35d991ffd0c81e3023e7462c00558a49 (patch)
treec58a9cc45ac1909a9a0f9e2918fbce185577079b
parent509570015064580054a5ea0c3df3d07906433305 (diff)
downloadtox-passenv_multiline.tar.gz
make passenv attribute type line-listpassenv_multiline
-rw-r--r--tests/test_config.py24
-rw-r--r--tox/config.py10
2 files changed, 27 insertions, 7 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index f85b563..fae1bde 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -733,6 +733,7 @@ class TestConfigTestEnv:
config = newconfig("""
[testenv]
passenv =
+ # comment
A123* B?23
""")
assert len(config.envconfigs) == 1
@@ -754,20 +755,39 @@ class TestConfigTestEnv:
def test_passenv_with_factor(self, tmpdir, newconfig, monkeypatch):
monkeypatch.setenv("A123A", "a")
monkeypatch.setenv("A123B", "b")
+ monkeypatch.setenv("A123C", "c")
+ monkeypatch.setenv("A123D", "d")
monkeypatch.setenv("BX23", "0")
+ monkeypatch.setenv("CCA43", "3")
+ monkeypatch.setenv("CB21", "4")
config = newconfig("""
[tox]
envlist = {x1,x2}
[testenv]
passenv =
- x1: A123A
- x2: A123B
+ x1: A123A CC*
+ x1: CB21
+ # passed to both environments
+ A123C
+ x2: A123B A123D
""")
assert len(config.envconfigs) == 2
+
assert "A123A" in config.envconfigs["x1"].passenv
+ assert "A123C" in config.envconfigs["x1"].passenv
+ assert "CCA43" in config.envconfigs["x1"].passenv
+ assert "CB21" in config.envconfigs["x1"].passenv
assert "A123B" not in config.envconfigs["x1"].passenv
+ assert "A123D" not in config.envconfigs["x1"].passenv
+ assert "BX23" not in config.envconfigs["x1"].passenv
+
assert "A123B" in config.envconfigs["x2"].passenv
+ assert "A123D" in config.envconfigs["x2"].passenv
assert "A123A" not in config.envconfigs["x2"].passenv
+ assert "A123C" in config.envconfigs["x2"].passenv
+ assert "CCA43" not in config.envconfigs["x2"].passenv
+ assert "CB21" not in config.envconfigs["x2"].passenv
+ assert "BX23" not in config.envconfigs["x2"].passenv
def test_changedir_override(self, tmpdir, newconfig):
config = newconfig("""
diff --git a/tox/config.py b/tox/config.py
index 5dba0bc..062992e 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -381,10 +381,10 @@ def tox_addoption(parser):
help="list of X=Y lines with environment variable settings")
def passenv(testenv_config, value):
- if len(value) == 1 and "\n" in value[0]:
- # If we have a list of 1 element that contains new lines,
- # passenv has been specified as a multi line list.
- value = value[0].split("\n")
+ # Flatten the list to deal with space-separated values.
+ value = list(
+ itertools.chain.from_iterable(
+ [x.split(' ') for x in value]))
passenv = set(["PATH", "PIP_INDEX_URL", "LANG"])
@@ -407,7 +407,7 @@ def tox_addoption(parser):
return passenv
parser.add_testenv_attribute(
- name="passenv", type="space-separated-list", postprocess=passenv,
+ name="passenv", type="line-list", postprocess=passenv,
help="environment variables needed during executing test commands "
"(taken from invocation environment). Note that tox always "
"passes through some basic environment variables which are "