3 new commits in tox: https://bitbucket.org/hpk42/tox/commits/66756a0fabc6/ Changeset: 66756a0fabc6 User: nakatoio Date: 2016-02-11 02:46:02+00:00 Summary: Add test for subsitition from other section with posargs
Test command substitution from other section with {posargs} in use. Issue #279 Affected #: 1 file diff -r 2d5d0e7584cc4cc35cc7e0519ce9610dd52b7a62 -r 66756a0fabc6b74d7cc47629b9335992987ab3ad tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -274,6 +274,20 @@ ["echo", "cmd", "1", "2", "3", "4", "cmd", "2"], ] + def test_command_substitution_from_other_section_posargs(self, newconfig): + """Ensure subsitition from other section with posargs succeeds""" + config = newconfig(""" + [section] + key = thing {posargs} arg2 + [testenv] + commands = + {[section]key} + """) + reader = SectionReader("testenv", config._cfg) + reader.addsubstitutions([r"argpos"]) + x = reader.getargvlist("commands") + assert x == [['thing', 'argpos' 'arg2']] + def test_command_env_substitution(self, newconfig): """Ensure referenced {env:key:default} values are substituted correctly.""" config = newconfig(""" https://bitbucket.org/hpk42/tox/commits/7a5151487905/ Changeset: 7a5151487905 User: nakatoio Date: 2016-02-11 04:54:23+00:00 Summary: Fix section substitution with {posargs} Use crossonly to stop substitution immediately after the section is substituted, the values run through substitution again afterwards, and this will clean off {posargs} and any other substitutions that need to be made. Affected #: 2 files diff -r 66756a0fabc6b74d7cc47629b9335992987ab3ad -r 7a5151487905f30101309bc43b387760c66b8771 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -286,7 +286,7 @@ reader = SectionReader("testenv", config._cfg) reader.addsubstitutions([r"argpos"]) x = reader.getargvlist("commands") - assert x == [['thing', 'argpos' 'arg2']] + assert x == [['thing', 'argpos', 'arg2']] def test_command_env_substitution(self, newconfig): """Ensure referenced {env:key:default} values are substituted correctly.""" diff -r 66756a0fabc6b74d7cc47629b9335992987ab3ad -r 7a5151487905f30101309bc43b387760c66b8771 tox/config.py --- a/tox/config.py +++ b/tox/config.py @@ -1094,7 +1094,7 @@ current_command += line if is_section_substitution(current_command): - replaced = reader._replace(current_command) + replaced = reader._replace(current_command, crossonly=True) commands.extend(cls.getargvlist(reader, replaced)) else: commands.append(cls.processcommand(reader, current_command)) https://bitbucket.org/hpk42/tox/commits/ddf15d86a209/ Changeset: ddf15d86a209 User: hpk42 Date: 2016-02-11 17:05:32+00:00 Summary: Merged in nakatoio/tox (pull request #189) Fix section substitution with {posargs} Affected #: 2 files diff -r bfe2e9b0a5ef459d4a57f695c6aa9e7cf0fa99a4 -r ddf15d86a2097e8d94fca572865fda556dca2623 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -274,6 +274,20 @@ ["echo", "cmd", "1", "2", "3", "4", "cmd", "2"], ] + def test_command_substitution_from_other_section_posargs(self, newconfig): + """Ensure subsitition from other section with posargs succeeds""" + config = newconfig(""" + [section] + key = thing {posargs} arg2 + [testenv] + commands = + {[section]key} + """) + reader = SectionReader("testenv", config._cfg) + reader.addsubstitutions([r"argpos"]) + x = reader.getargvlist("commands") + assert x == [['thing', 'argpos', 'arg2']] + def test_command_env_substitution(self, newconfig): """Ensure referenced {env:key:default} values are substituted correctly.""" config = newconfig(""" diff -r bfe2e9b0a5ef459d4a57f695c6aa9e7cf0fa99a4 -r ddf15d86a2097e8d94fca572865fda556dca2623 tox/config.py --- a/tox/config.py +++ b/tox/config.py @@ -1094,7 +1094,7 @@ current_command += line if is_section_substitution(current_command): - replaced = reader._replace(current_command) + replaced = reader._replace(current_command, crossonly=True) commands.extend(cls.getargvlist(reader, replaced)) else: commands.append(cls.processcommand(reader, current_command)) 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