From a3c4eb4a7c0f5128948e7346e900a5d79d85ecb0 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Thu, 3 Apr 2014 15:45:55 -0700 Subject: Allow backslashing curly braces to prevent expansion e.g.: commands=echo \{posargs\} = {posargs} --- tox/_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox/_config.py b/tox/_config.py index 6006fa9..4d54924 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -451,8 +451,8 @@ class IndexServerConfig: self.url = url RE_ITEM_REF = re.compile( - ''' - [{] + r''' + (?[^[:{}]+):)? # optional sub_type for special rules (?P[^{}]*) # substitution key [}] @@ -686,7 +686,7 @@ class CommandParser(object): def word_has_ended(): return ((cur_char in string.whitespace and ps.word and ps.word[-1] not in string.whitespace) or - (cur_char == '{' and ps.depth == 0) or + (cur_char == '{' and ps.depth == 0 and not ps.word.endswith('\\')) or (ps.depth == 0 and ps.word and ps.word[-1] == '}') or (cur_char not in string.whitespace and ps.word and ps.word.strip() == '')) -- cgit v1.2.1 From d37e3d69bf0496828eaf140f16d53db5ae9c8c80 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Sun, 11 May 2014 22:44:09 -0700 Subject: Add test_posargs_backslashed_or_quoted --- tests/test_config.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index b8d0aa3..c4ec9cc 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -663,6 +663,23 @@ class TestConfigTestEnv: assert argv[0] == ["cmd1", "[hello]", "world"] assert argv[1] == ["cmd1", "brave", "new", "world"] + def test_posargs_backslashed_or_quoted(self, tmpdir, newconfig): + inisource = """ + [testenv:py24] + commands = + echo "\{posargs\}" = {posargs} + echo "posargs = " "{posargs}" + """ + conf = newconfig([], inisource).envconfigs['py24'] + argv = conf.commands + assert argv[0] == ['echo', '\\{posargs\\}', '='] + assert argv[1] == ['echo', 'posargs ='] + + conf = newconfig(['dog', 'cat'], inisource).envconfigs['py24'] + argv = conf.commands + assert argv[0] == ['echo', '\\{posargs\\}', '=', 'dog', 'cat'] + assert argv[1] == ['echo', 'posargs =', 'dog', 'cat'] + def test_rewrite_posargs(self, tmpdir, newconfig): inisource = """ [testenv:py24] -- cgit v1.2.1 From a06d5df17553b2ef51b092b1aa83db35f967c546 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 26 Sep 2014 15:36:48 +0000 Subject: Allow "." in factor names for multi-dimensional tests. --- tox/_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox/_config.py b/tox/_config.py index 3c1b8c2..5e8765b 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -305,7 +305,7 @@ class parseini: factors = set() if section in self._cfg: for _, value in self._cfg[section].items(): - exprs = re.findall(r'^([\w{},-]+)\:\s+', value, re.M) + exprs = re.findall(r'^([\w{}\.,-]+)\:\s+', value, re.M) factors.update(*mapcat(_split_factor_expr, exprs)) return factors -- cgit v1.2.1 From 73e938245015e1e19ae6decd6671be3b98c06c60 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 26 Sep 2014 19:32:11 +0000 Subject: Added a test for period in factor --- tests/test_config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index bf74133..615de30 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -909,6 +909,14 @@ class TestConfigTestEnv: configs = newconfig([], inisource).envconfigs assert configs["py27"].setenv["X"] == "1" assert "X" not in configs["py26"].setenv + + def test_period_in_factor(self, newconfig): + inisource=""" + [tox] + envlist = py27-{django1.6,django1.7} + """ + configs = newconfig([], inisource).envconfigs + assert list(configs) == ["py27-django1.6", "py27-django-1.7"] class TestGlobalOptions: -- cgit v1.2.1 From f21eb4bba1e7d18b7718aeaadb9384dd74fcf8e6 Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Sun, 12 Oct 2014 23:10:19 +0800 Subject: Recognize period in envnames in factor conditions --- tests/test_config.py | 15 +++++++++++---- tox/_config.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index 615de30..43b5a34 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -909,14 +909,21 @@ class TestConfigTestEnv: configs = newconfig([], inisource).envconfigs assert configs["py27"].setenv["X"] == "1" assert "X" not in configs["py26"].setenv - + def test_period_in_factor(self, newconfig): inisource=""" - [tox] - envlist = py27-{django1.6,django1.7} + [tox] + envlist = py27-{django1.6,django1.7} + + [testenv] + deps = + django1.6: Django==1.6 + django1.7: Django==1.7 """ configs = newconfig([], inisource).envconfigs - assert list(configs) == ["py27-django1.6", "py27-django-1.7"] + assert sorted(configs) == ["py27-django1.6", "py27-django1.7"] + assert [d.name for d in configs["py27-django1.6"].deps] \ + == ["Django==1.6"] class TestGlobalOptions: diff --git a/tox/_config.py b/tox/_config.py index 5e8765b..5d259c4 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -642,7 +642,7 @@ class IniReader: def _apply_factors(self, s): def factor_line(line): - m = re.search(r'^([\w{},-]+)\:\s+(.+)', line) + m = re.search(r'^([\w{}\.,-]+)\:\s+(.+)', line) if not m: return line -- cgit v1.2.1