diff options
| author | Clark Boylan <clark.boylan@gmail.com> | 2014-02-07 20:33:48 -0800 |
|---|---|---|
| committer | Clark Boylan <clark.boylan@gmail.com> | 2014-02-07 20:33:48 -0800 |
| commit | 23380da3f729a37106cc6ca2023429bdb547c780 (patch) | |
| tree | f7f0572927aae15af5f7cfb9e67d6021e3f8efb7 /tests | |
| parent | b77b75f4655480b32475f2bb1efaa592516db30c (diff) | |
| download | tox-23380da3f729a37106cc6ca2023429bdb547c780.tar.gz | |
Add tests for posargs quoting.
Two new tests ensure posargs quoting works as expected. When {posargs}
is surrounded by quotes in the commands list the contents of posargs
should be a single entry in the argv list for the commands. When the
posargs themselves include quotes the same behavior should occur.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_config.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py index 7ffc4f5..93d7659 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -346,6 +346,34 @@ class TestIniParser: assert argvlist[0] == ["cmd1"] assert argvlist[1] == ["cmd2", "value2", "other"] + def test_argvlist_quoted_posargs(self, tmpdir, newconfig): + config = newconfig(""" + [section] + key2= + cmd1 --foo-args='{posargs}' + cmd2 -f '{posargs}' + cmd3 -f {posargs} + """) + reader = IniReader(config._cfg) + reader.addsubstitutions(["foo", "bar"]) + assert reader.getargvlist('section', 'key1') == [] + x = reader.getargvlist("section", "key2") + assert x == [["cmd1", "--foo-args=foo bar"], + ["cmd2", "-f", "foo bar"], + ["cmd3", "-f", "foo", "bar"]] + + def test_argvlist_posargs_with_quotes(self, tmpdir, newconfig): + config = newconfig(""" + [section] + key2= + cmd1 -f {posargs} + """) + reader = IniReader(config._cfg) + reader.addsubstitutions(["foo", "'bar", "baz'"]) + assert reader.getargvlist('section', 'key1') == [] + x = reader.getargvlist("section", "key2") + assert x == [["cmd1", "-f", "foo", "bar baz"]] + def test_positional_arguments_are_only_replaced_when_standing_alone(self, tmpdir, newconfig): config = newconfig(""" |
