From fe8a1ba5216c71421f8a83ef62f3aabed634371b Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 26 Dec 2015 09:16:05 +1100 Subject: Unescape \{..\} --- tests/test_config.py | 4 ++-- tox/config.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index 6176641..7c0e411 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1015,12 +1015,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 079dff3..230508d 100644 --- a/tox/config.py +++ b/tox/config.py @@ -1129,6 +1129,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 -- cgit v1.2.1 From fcc2506142ce6b0b3df29586c8f9ad6ac2a014b8 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 26 Dec 2015 16:22:49 +1100 Subject: Add test for double substitution using {{ }} {{foo}} uses the result of {foo} as the name for substitution. --- tests/test_config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index 6176641..a027e91 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1006,6 +1006,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] -- cgit v1.2.1 -- cgit v1.2.1 From b47956354960dcae6de72300cfa8d9d341d43f2b Mon Sep 17 00:00:00 2001 From: joshpere Date: Thu, 14 Apr 2016 11:59:37 -0700 Subject: Cleanup: Rename local variable for clarity --- tox/venv.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tox/venv.py b/tox/venv.py index 2e46098..35a50e5 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -88,29 +88,29 @@ class VirtualEnv(object): 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) + path = None 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 = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) + if path is not None: + return path + path = py.path.local.sysfind(name) + if path is None: raise tox.exception.InvocationError( "could not find executable %r" % (name,)) - # p is not found in virtualenv script/bin dir + # path is not found in virtualenv script/bin dir if venv: - if not self.is_allowed_external(p): + 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)) + return str(path) # will not be rewritten for reporting def is_allowed_external(self, p): tryadd = [""] -- cgit v1.2.1 From 6d00104096a4986308df8f737460fb9d0716504d Mon Sep 17 00:00:00 2001 From: joshpere Date: Thu, 14 Apr 2016 12:04:20 -0700 Subject: Cleanup: Format comments for easier reading. --- tox/venv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tox/venv.py b/tox/venv.py index 35a50e5..fb6ed77 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -79,11 +79,11 @@ class VirtualEnv(object): return "" % (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 -- cgit v1.2.1 From b7339866040d05986ffc5ca2a1c275c9a56fb3fa Mon Sep 17 00:00:00 2001 From: joshpere Date: Thu, 14 Apr 2016 12:15:42 -0700 Subject: Cleanup: Extract function for readability. The _venv_lookup function is now self-descriptive and more self-contained. --- tox/venv.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tox/venv.py b/tox/venv.py index fb6ed77..c75b75e 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -91,17 +91,22 @@ class VirtualEnv(object): path = cwd.join(name) if path.check(): return str(path) - path = None + if venv: - path = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) - if path is not None: - return path - path = py.path.local.sysfind(name) + path = self._venv_lookup(name) + else: + path = py.path.local.sysfind(name) + if path is None: raise tox.exception.InvocationError( "could not find executable %r" % (name,)) - # path is not found in virtualenv script/bin dir - if venv: + + return str(path) # will not be rewritten for reporting + + def _venv_lookup(self, name): + path = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) + if path is None: + path = py.path.local.sysfind(name) if not self.is_allowed_external(path): self.session.report.warning( "test command found but not installed in testenv\n" @@ -110,7 +115,7 @@ class VirtualEnv(object): "Maybe you forgot to specify a dependency? " "See also the whitelist_externals envconfig setting." % ( path, self.envconfig.envdir)) - return str(path) # will not be rewritten for reporting + return path def is_allowed_external(self, p): tryadd = [""] -- cgit v1.2.1 From a7641bd69c70cf2a98a114ddd8abb09256322789 Mon Sep 17 00:00:00 2001 From: joshpere Date: Thu, 14 Apr 2016 12:18:29 -0700 Subject: Cleanup: Extract duplicate code --- tox/venv.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tox/venv.py b/tox/venv.py index c75b75e..a943ec4 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -95,7 +95,7 @@ class VirtualEnv(object): if venv: path = self._venv_lookup(name) else: - path = py.path.local.sysfind(name) + path = self._normal_lookup(name) if path is None: raise tox.exception.InvocationError( @@ -106,7 +106,7 @@ class VirtualEnv(object): def _venv_lookup(self, name): path = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) if path is None: - path = py.path.local.sysfind(name) + path = self._normal_lookup(name) if not self.is_allowed_external(path): self.session.report.warning( "test command found but not installed in testenv\n" @@ -117,6 +117,9 @@ class VirtualEnv(object): path, self.envconfig.envdir)) return path + def _normal_lookup(self, name): + return py.path.local.sysfind(name) + def is_allowed_external(self, p): tryadd = [""] if sys.platform == "win32": -- cgit v1.2.1 From 027201aaecfcc0ad14602bf25b368473306cc33d Mon Sep 17 00:00:00 2001 From: joshpere Date: Thu, 14 Apr 2016 12:32:18 -0700 Subject: Cleanup: Renaming and method extraction. --- tox/venv.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tox/venv.py b/tox/venv.py index a943ec4..f6dabfc 100644 --- a/tox/venv.py +++ b/tox/venv.py @@ -93,7 +93,7 @@ class VirtualEnv(object): return str(path) if venv: - path = self._venv_lookup(name) + path = self._venv_lookup_and_check_external_whitelist(name) else: path = self._normal_lookup(name) @@ -103,22 +103,29 @@ class VirtualEnv(object): return str(path) # will not be rewritten for reporting - def _venv_lookup(self, name): - path = py.path.local.sysfind(name, paths=[self.envconfig.envbindir]) + def _venv_lookup_and_check_external_whitelist(self, name): + path = self._venv_lookup(name) if path is None: path = self._normal_lookup(name) - if not self.is_allowed_external(path): - self.session.report.warning( + 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." % ( path, self.envconfig.envdir)) - return path - - def _normal_lookup(self, name): - return py.path.local.sysfind(name) def is_allowed_external(self, p): tryadd = [""] -- cgit v1.2.1 From 583c213aa47c70183cf7a467ee6932e0775d4041 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 20 Jun 2016 18:21:40 +0200 Subject: add changelog entry for latest PR merge: 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. --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 26447a4..be3ed89 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. -- cgit v1.2.1 From efd37f7e197339af18ae3bb2ec225c33b2c739b9 Mon Sep 17 00:00:00 2001 From: Danielle Jenkins Date: Mon, 20 Jun 2016 18:42:16 +0200 Subject: Add changelog message for config file prefixes. --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index be3ed89..c4a63e0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,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 ----- -- cgit v1.2.1