[Pytest-commit] commit/tox: hpk42: Merged in stefano-m/tox/passenv_multiline (pull request #166)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Jun 19 11:10:20 CEST 2015
1 new commit in tox:
https://bitbucket.org/hpk42/tox/commits/37c6dac2b848/
Changeset: 37c6dac2b848
User: hpk42
Date: 2015-06-19 09:10:16+00:00
Summary: Merged in stefano-m/tox/passenv_multiline (pull request #166)
Issue #259 passenv statement should accept multi-line list
Affected #: 2 files
diff -r 673d3f1f8d095cd8e1733506ffdc2f162b93e59b -r 37c6dac2b8484bb084dd6fff81fde108e5b96a4c tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -696,14 +696,45 @@
assert envconfig.setenv['ANOTHER_VAL'] == 'else'
@pytest.mark.parametrize("plat", ["win32", "linux2"])
- def test_passenv(self, tmpdir, newconfig, monkeypatch, plat):
+ def test_passenv_as_multiline_list(self, tmpdir, newconfig, monkeypatch, plat):
monkeypatch.setattr(sys, "platform", plat)
monkeypatch.setenv("A123A", "a")
monkeypatch.setenv("A123B", "b")
monkeypatch.setenv("BX23", "0")
config = newconfig("""
[testenv]
- passenv = A123* B?23
+ passenv =
+ A123*
+ # isolated comment
+ B?23
+ """)
+ assert len(config.envconfigs) == 1
+ envconfig = config.envconfigs['python']
+ if plat == "win32":
+ assert "PATHEXT" in envconfig.passenv
+ assert "SYSTEMDRIVE" in envconfig.passenv
+ assert "SYSTEMROOT" in envconfig.passenv
+ assert "TEMP" in envconfig.passenv
+ assert "TMP" in envconfig.passenv
+ else:
+ assert "TMPDIR" in envconfig.passenv
+ assert "PATH" in envconfig.passenv
+ assert "PIP_INDEX_URL" in envconfig.passenv
+ assert "LANG" in envconfig.passenv
+ assert "A123A" in envconfig.passenv
+ assert "A123B" in envconfig.passenv
+
+ @pytest.mark.parametrize("plat", ["win32", "linux2"])
+ def test_passenv_as_space_separated_list(self, tmpdir, newconfig, monkeypatch, plat):
+ monkeypatch.setattr(sys, "platform", plat)
+ monkeypatch.setenv("A123A", "a")
+ monkeypatch.setenv("A123B", "b")
+ monkeypatch.setenv("BX23", "0")
+ config = newconfig("""
+ [testenv]
+ passenv =
+ # comment
+ A123* B?23
""")
assert len(config.envconfigs) == 1
envconfig = config.envconfigs['python']
@@ -724,20 +755,39 @@
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 -r 673d3f1f8d095cd8e1733506ffdc2f162b93e59b -r 37c6dac2b8484bb084dd6fff81fde108e5b96a4c tox/config.py
--- a/tox/config.py
+++ b/tox/config.py
@@ -381,6 +381,11 @@
help="list of X=Y lines with environment variable settings")
def passenv(testenv_config, value):
+ # 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"])
# we ensure that tmp directory settings are passed on
@@ -402,7 +407,7 @@
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 "
Repository URL: https://bitbucket.org/hpk42/tox/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list