1 new commit in tox: https://bitbucket.org/hpk42/tox/commits/88a503e7e5ae/ Changeset: 88a503e7e5ae User: hpk42 Date: 2013-10-14 12:04:28 Summary: fix parsing/escaping bugs on windows32 Affected #: 3 files
diff -r df35850bb8d3d8a482f4415a6cab86dad23c951a -r 88a503e7e5aefe509be8f6c3108a84baa20c3c26 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,8 @@ - fix issue128: enable full substitution in install_command, thanks for the PR to Ronald Evers +- fix windows parsing/escaping + 1.6.1 ----- diff -r df35850bb8d3d8a482f4415a6cab86dad23c951a -r 88a503e7e5aefe509be8f6c3108a84baa20c3c26 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -243,6 +243,16 @@ assert x == [["cmd1", "with space", "grr"], ["cmd2", "grr"]] + def test_argvlist_windows_escaping(self, tmpdir, newconfig): + config = newconfig(""" + [section] + comm = py.test {posargs} + """) + reader = IniReader(config._cfg) + reader.addsubstitutions([r"hello\this"]) + argv = reader.getargv("section", "comm") + assert argv == ["py.test", "hello\\this"] + def test_argvlist_multiline(self, tmpdir, newconfig): config = newconfig(""" [section] @@ -1077,3 +1087,15 @@ p = CommandParser(cmd) parsed = list(p.words()) assert parsed == ['nosetests', ' ', '-v', ' ', '-a', ' ', '!deferred', ' ', '--with-doctest', ' ', '[]'] + +def test_argv_unquote_single_args(): + argv = ["hello", '"hello2"', "'hello3'"] + newargv = unquote_single_args(argv) + assert newargv == ["hello", "hello2", "hello3"] + +def test_argv_roundrobin(): + argv = ["hello", "this\\that"] + assert string2argv(argv2string(argv)) == argv + argv = ["hello world"] + assert string2argv(argv2string(argv)) == argv + diff -r df35850bb8d3d8a482f4415a6cab86dad23c951a -r 88a503e7e5aefe509be8f6c3108a84baa20c3c26 tox/_config.py --- a/tox/_config.py +++ b/tox/_config.py @@ -14,6 +14,7 @@ import tox +iswin32 = sys.platform == "win32" defaultenvs = {'jython': 'jython', 'pypy': 'pypy'} for _name in "py,py24,py25,py26,py27,py30,py31,py32,py33,py34".split(","): @@ -487,7 +488,7 @@ command = self.getdefault( section, name, default=default, replace=replace) - return shlex.split(command.strip()) + return string2argv(command.strip()) def getbool(self, section, name, default=None): s = self.getdefault(section, name, default) @@ -533,7 +534,7 @@ posargs = self._subs.get('_posargs', None) if posargs: - return " ".join(posargs) + return argv2string(posargs) value = value_func() if value: @@ -704,3 +705,19 @@ if 'HUDSON_URL' in os.environ: return 'jenkins' return None + + +def unquote_single_args(argv): + newargv = [] + for arg in argv: + if len(arg) >=2 and arg[0] == arg[-1]: + if arg[0] in ("'", '"'): + arg = arg[1:-1] + newargv.append(arg) + return newargv + +def string2argv(cmd): + return unquote_single_args(shlex.split(cmd, posix=False)) + +def argv2string(argv): + return subprocess.list2cmdline(argv) 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