1 new commit in tox: https://bitbucket.org/hpk42/tox/commits/763eeed49a7c/ Changeset: 763eeed49a7c User: hpk42 Date: 2015-10-30 09:26:00+00:00 Summary: Merged in itxaka/tox/fix_env_use (pull request #169)
Tries to fix #99 Affected #: 2 files diff -r 7e30b4b4591bb51fae92791a60adc98fe21733bb -r 763eeed49a7c572a9c31940932cfbeaff8d32ab1 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -254,6 +254,28 @@ ["echo", "cmd", "1", "2", "3", "4", "cmd", "2"], ] + def test_command_env_substitution(self, newconfig): + """Ensure referenced {env:key:default} values are substituted correctly.""" + config = newconfig(""" + [testenv:py27] + setenv = + TEST=testvalue + commands = + ls {env:TEST} + """) + reader = SectionReader("testenv:py27", config._cfg) + x = reader.getargvlist("commands") + assert x == [ + "ls testvalue".split() + ] + assert x != [ + "ls {env:TEST}".split() + ] + y = reader.getargvlist("setenv") + assert y == [ + "TEST=testvalue".split() + ] + class TestIniParser: def test_getstring_single(self, tmpdir, newconfig): diff -r 7e30b4b4591bb51fae92791a60adc98fe21733bb -r 763eeed49a7c572a9c31940932cfbeaff8d32ab1 tox/config.py --- a/tox/config.py +++ b/tox/config.py @@ -902,6 +902,7 @@ return '\n'.join(filter(None, map(factor_line, lines))) def _replace_env(self, match): + env_list = self.getdict('setenv') match_value = match.group('substitution_value') if not match_value: raise tox.exception.ConfigError( @@ -916,11 +917,14 @@ envkey = match_value if envkey not in os.environ and default is None: - raise tox.exception.ConfigError( - "substitution env:%r: unknown environment variable %r" % - (envkey, envkey)) - - return os.environ.get(envkey, default) + if envkey not in env_list and default is None: + raise tox.exception.ConfigError( + "substitution env:%r: unknown environment variable %r" % + (envkey, envkey)) + if envkey in os.environ: + return os.environ.get(envkey, default) + else: + return env_list.get(envkey, default) def _substitute_from_other_section(self, key): if key.startswith("[") and "]" in key: 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. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit