Skip to content

Commit

Permalink
Make substitution engine ignore factor arrays, fix #302
Browse files Browse the repository at this point in the history
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.

--HG--
branch : issue302
  • Loading branch information
AndreiPashkin committed Sep 9, 2016
1 parent 6c62be2 commit 174bf2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,20 +1154,32 @@ def test_rewrite_simple_posargs(self, tmpdir, newconfig):
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 = """
Expand Down
2 changes: 1 addition & 1 deletion tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 174bf2d

Please sign in to comment.