Skip to content

Commit

Permalink
Merge pull request #1656 from mkenigs/escape-braces-in-setenv
Browse files Browse the repository at this point in the history
Allow escaping curly braces in setenv
  • Loading branch information
gaborbernat authored Aug 31, 2020
2 parents 8e39dfb + 3c38762 commit d4e6e77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Mariusz Rusiniak
Mark Hirota
Matt Good
Matt Jeffery
Matthew Kenigsberg
Mattieu Agopian
Mehdi Abaakouk
Michael Manganiello
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1656.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow escaping curly braces in setenv. - by :user:`mkenigs`
4 changes: 3 additions & 1 deletion src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ def get(self, name, default=None):
return os.environ.get(name, default)
self._lookupstack.append(name)
try:
self.resolved[name] = res = self.reader._replace(val)
res = self.reader._replace(val)
res = res.replace("\\{", "{").replace("\\}", "}")
self.resolved[name] = res
finally:
self._lookupstack.pop()
return res
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,15 @@ def test_factors_in_setenv(self, newconfig):
assert configs["py27"].setenv["X"] == "1"
assert "X" not in configs["py36"].setenv

def test_curly_braces_in_setenv(self, newconfig):
inisource = r"""
[testenv]
setenv =
VAR = \{val\}
"""
configs = newconfig([], inisource).envconfigs
assert configs["python"].setenv["VAR"] == "{val}"

def test_factor_use_not_checked(self, newconfig):
inisource = """
[tox]
Expand Down

0 comments on commit d4e6e77

Please sign in to comment.