summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2014-10-14 10:10:18 +0200
committerholger krekel <holger@merlinux.eu>2014-10-14 10:10:18 +0200
commit1d7b2c568c940a1fc160b7e622622b33db9f4ee5 (patch)
tree4ed1f926adcce06c2ee4abba521433bef0e42ff8
parentf0c0c9649ad003edd86d88ee267d53e34216213d (diff)
parentd37e3d69bf0496828eaf140f16d53db5ae9c8c80 (diff)
downloadtox-1d7b2c568c940a1fc160b7e622622b33db9f4ee5.tar.gz
Merged in msabramo/tox/allow_backslash_escape_curly_braces_msabramo_2 (pull request #93)
Allow backslashing curly braces to prevent expansion
-rw-r--r--tests/test_config.py17
-rw-r--r--tox/_config.py6
2 files changed, 20 insertions, 3 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 43b5a34..c823cb3 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -706,6 +706,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]
diff --git a/tox/_config.py b/tox/_config.py
index 5d259c4..f0ad87e 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -484,8 +484,8 @@ class IndexServerConfig:
self.url = url
RE_ITEM_REF = re.compile(
- '''
- [{]
+ r'''
+ (?<!\\)[{]
(?:(?P<sub_type>[^[:{}]+):)? # optional sub_type for special rules
(?P<substitution_value>[^{}]*) # substitution key
[}]
@@ -752,7 +752,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() == ''))