From 4d51de7c16dddee793da14e319ad86c686ff5be1 Mon Sep 17 00:00:00 2001 From: Andrei Pashkin Date: Fri, 9 Sep 2016 14:45:54 +0300 Subject: Make substitution engine ignore factor arrays, fix #302 The fix assumes, that the bug was that the substitution engine - tox.config.Replacer, while recursvely replacing references to actual values, treated factor arrays (like {py27,py34}) as references, that are needed to be replaced, which they are not. The patch simply amends regex which is used by Replacer to recognize references, to ignore factor arrays. And factor arrays assumed to be values, enclosed in curly braces, that contain at least one comma. --- tests/test_config.py | 26 +++++++++++++++++++------- tox/config.py | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index 9eb955d..d685ac8 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1154,20 +1154,32 @@ class TestConfigTestEnv: argv = conf.commands assert argv[0] == ["cmd1", "hello"] - def test_take_dependencies_from_other_testenv(self, newconfig): + @pytest.mark.parametrize('envlist, deps', [ + (['py27'], ('pytest', 'pytest-cov')), + (['py27', 'py34'], ('pytest', 'py{27,34}: pytest-cov')), + ]) + def test_take_dependencies_from_other_testenv( + self, + newconfig, + envlist, + deps + ): inisource = """ + [tox] + envlist = {envlist} [testenv] - deps= - pytest - pytest-cov + deps={deps} [testenv:py27] deps= - {[testenv]deps} + {{[testenv]deps}} fun - """ + """.format( + envlist=','.join(envlist), + deps='\n' + '\n'.join([' ' * 17 + d for d in deps]) + ) conf = newconfig([], inisource).envconfigs['py27'] packages = [dep.name for dep in conf.deps] - assert packages == ['pytest', 'pytest-cov', 'fun'] + assert packages == list(deps) + ['fun'] def test_take_dependencies_from_other_section(self, newconfig): inisource = """ diff --git a/tox/config.py b/tox/config.py index ad453f6..d6b4c52 100644 --- a/tox/config.py +++ b/tox/config.py @@ -1017,7 +1017,7 @@ class Replacer: r''' (?[^[:{}]+):)? # optional sub_type for special rules - (?P[^{}]*) # substitution key + (?P[^,{}]*) # substitution key [}] ''', re.VERBOSE) -- cgit v1.2.1