diff options
author | Steffen Allner <sa@gocept.com> | 2016-06-20 18:35:39 +0200 |
---|---|---|
committer | Steffen Allner <sa@gocept.com> | 2016-06-20 18:35:39 +0200 |
commit | 3b59bea054112672209682a9f8c81799ac8d22df (patch) | |
tree | 7ccd17c342b60c925372686d62cc974f14e193cc | |
parent | 59eeb645f38fff2828a0d9f0c72c4a2d39f638b6 (diff) | |
parent | efd37f7e197339af18ae3bb2ec225c33b2c739b9 (diff) | |
download | tox-3b59bea054112672209682a9f8c81799ac8d22df.tar.gz |
Merge from default.
-rw-r--r-- | CHANGELOG | 6 | ||||
-rw-r--r-- | tests/test_config.py | 18 | ||||
-rw-r--r-- | tox/config.py | 1 | ||||
-rw-r--r-- | tox/venv.py | 55 |
4 files changed, 58 insertions, 22 deletions
@@ -1,6 +1,10 @@ 2.4.0 ----- +- fix issue212: allow escaping curly brace chars "\{" and "\}" if you need the + chars "{" and "}" to appear in your commands or other ini values. + Thanks John Vandenberg. + - add --workdir option to override where tox stores its ".tox" directory and all of the virtualenv environment. Thanks Danring. @@ -15,6 +19,8 @@ something like "pip install {opts} {packages}". Thanks Ted Shaw, Holger Krekel. +- New feature: When a search for a config file fails, tox tries loading + setup.cfg with a section prefix of "tox". 2.3.2 ----- diff --git a/tests/test_config.py b/tests/test_config.py index 08b2f23..2b81fa3 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1083,6 +1083,20 @@ class TestConfigTestEnv: argv = conf.commands assert argv[0] == ["echo"] + def test_substitution_double(self, newconfig): + inisource = """ + [params] + foo = bah + foo2 = [params]foo + + [testenv:py27] + commands = + echo {{[params]foo2}} + """ + conf = newconfig([], inisource).envconfigs['py27'] + argv = conf.commands + assert argv[0] == ['echo', 'bah'] + def test_posargs_backslashed_or_quoted(self, tmpdir, newconfig): inisource = """ [testenv:py27] @@ -1092,12 +1106,12 @@ class TestConfigTestEnv: """ conf = newconfig([], inisource).envconfigs['py27'] argv = conf.commands - assert argv[0] == ['echo', '\\{posargs\\}', '='] + assert argv[0] == ['echo', '{posargs}', '='] assert argv[1] == ['echo', 'posargs = ', ""] conf = newconfig(['dog', 'cat'], inisource).envconfigs['py27'] argv = conf.commands - assert argv[0] == ['echo', '\\{posargs\\}', '=', 'dog', 'cat'] + assert argv[0] == ['echo', '{posargs}', '=', 'dog', 'cat'] assert argv[1] == ['echo', 'posargs = ', 'dog cat'] def test_rewrite_posargs(self, tmpdir, newconfig): diff --git a/tox/config.py b/tox/config.py index 99e678d..0b90786 100644 --- a/tox/config.py +++ b/tox/config.py @@ -1166,6 +1166,7 @@ class _ArgvlistReader: new_arg = "" new_word = reader._replace(word) new_word = reader._replace(new_word) + new_word = new_word.replace('\\{', '{').replace('\\}', '}') new_arg += new_word newcommand += new_arg diff --git a/tox/venv.py b/tox/venv.py index 2e46098..f6dabfc 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -79,38 +79,53 @@ class VirtualEnv(object): return "<VirtualEnv at %r>" % (self.path) def getcommandpath(self, name, venv=True, cwd=None): - """ return absolute path (str or localpath) for specified - command name. If it's a localpath we will rewrite it as - as a relative path. If venv is True we will check if the - command is coming from the venv or is whitelisted to come - from external. """ + """ Return absolute path (str or localpath) for specified command name. + - If it's a local path we will rewrite it as as a relative path. + - If venv is True we will check if the command is coming from the venv + or is whitelisted to come from external. + """ name = str(name) if os.path.isabs(name): return name if os.path.split(name)[0] == ".": - p = cwd.join(name) - if p.check(): - return str(p) - p = None + path = cwd.join(name) + if path.check(): + return str(path) + if venv: - p = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) - if p is not None: - return p - p = py.path.local.sysfind(name) - if p is None: + path = self._venv_lookup_and_check_external_whitelist(name) + else: + path = self._normal_lookup(name) + + if path is None: raise tox.exception.InvocationError( "could not find executable %r" % (name,)) - # p is not found in virtualenv script/bin dir - if venv: - if not self.is_allowed_external(p): - self.session.report.warning( + + return str(path) # will not be rewritten for reporting + + def _venv_lookup_and_check_external_whitelist(self, name): + path = self._venv_lookup(name) + if path is None: + path = self._normal_lookup(name) + if path is not None: + self._check_external_allowed_and_warn(path) + return path + + def _venv_lookup(self, name): + return py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) + + def _normal_lookup(self, name): + return py.path.local.sysfind(name) + + def _check_external_allowed_and_warn(self, path): + if not self.is_allowed_external(path): + self.session.report.warning( "test command found but not installed in testenv\n" " cmd: %s\n" " env: %s\n" "Maybe you forgot to specify a dependency? " "See also the whitelist_externals envconfig setting." % ( - p, self.envconfig.envdir)) - return str(p) # will not be rewritten for reporting + path, self.envconfig.envdir)) def is_allowed_external(self, p): tryadd = [""] |