Skip to content

Commit 2e5e833

Browse files
committed
Allow escaping curly braces in setenv
Currently braces can be escaped, but the backslashes are not removed, making it impossible to add a plain curly brace
1 parent 23dd96f commit 2e5e833

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Mariusz Rusiniak
6767
Mark Hirota
6868
Matt Good
6969
Matt Jeffery
70+
Matthew Kenigsberg
7071
Mattieu Agopian
7172
Mehdi Abaakouk
7273
Michael Manganiello

docs/changelog/1656.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow escaping curly braces in setenv. - by :user:`mkenigs`

src/tox/config/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ def get(self, name, default=None):
382382
return os.environ.get(name, default)
383383
self._lookupstack.append(name)
384384
try:
385-
self.resolved[name] = res = self.reader._replace(val)
385+
res = self.reader._replace(val)
386+
res = res.replace("\\{", "{").replace("\\}", "}")
387+
self.resolved[name] = res
386388
finally:
387389
self._lookupstack.pop()
388390
return res

tests/unit/config/test_config.py

+9
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,15 @@ def test_factors_in_setenv(self, newconfig):
20742074
assert configs["py27"].setenv["X"] == "1"
20752075
assert "X" not in configs["py36"].setenv
20762076

2077+
def test_curly_braces_in_setenv(self, newconfig):
2078+
inisource = """
2079+
[testenv]
2080+
setenv =
2081+
VAR = \{val\}
2082+
"""
2083+
configs = newconfig([], inisource).envconfigs
2084+
assert configs["python"].setenv["VAR"] == "{val}"
2085+
20772086
def test_factor_use_not_checked(self, newconfig):
20782087
inisource = """
20792088
[tox]

0 commit comments

Comments
 (0)