summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Pashkin <andrew.pashkin@gmx.co.uk>2016-09-09 14:45:54 +0300
committerAndrei Pashkin <andrew.pashkin@gmx.co.uk>2016-09-09 14:45:54 +0300
commit4d51de7c16dddee793da14e319ad86c686ff5be1 (patch)
tree0bddb4ea8e912ab6ed1febc9d69c7e32ddf9490c
parent214ed8a7cde5f68882a566df86ce3878fa66ec77 (diff)
downloadtox-issue302.tar.gz
Make substitution engine ignore factor arrays, fix #302issue302
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.
-rw-r--r--tests/test_config.py26
-rw-r--r--tox/config.py2
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'''
(?<!\\)[{]
(?:(?P<sub_type>[^[:{}]+):)? # optional sub_type for special rules
- (?P<substitution_value>[^{}]*) # substitution key
+ (?P<substitution_value>[^,{}]*) # substitution key
[}]
''', re.VERBOSE)