Skip to content

Commit 489ad82

Browse files
authored
Fix section substitution with setenv (#3289)
1 parent 7317225 commit 489ad82

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

docs/changelog/3262.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix section substitution with setenv.

src/tox/config/set_env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def __iter__(self) -> Iterator[str]:
9393
expanded_line = self._replacer(line, ConfigLoadArgs([], self._name, self._env_name))
9494
sub_raw = dict(self._extract_key_value(sub_line) for sub_line in expanded_line.splitlines() if sub_line)
9595
self._raw.update(sub_raw)
96+
self.changed = True # loading while iterating can cause these values to be missed
9697
yield from sub_raw.keys()
9798

9899
def update(self, param: Mapping[str, str] | SetEnv, *, override: bool = True) -> None:

tests/tox_env/test_api.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ def test_dont_cleanup_temp_dir(tox_project: ToxProjectCreator, tmp_path: Path) -
2121
result = project.run()
2222
result.assert_success()
2323
assert (tmp_path / "foo" / "bar").exists()
24+
25+
26+
def test_setenv_section_substitution(tox_project: ToxProjectCreator) -> None:
27+
ini = """[variables]
28+
var = VAR = val
29+
[testenv]
30+
setenv = {[variables]var}
31+
commands = python -c 'import os; os.environ["VAR"]'"""
32+
project = tox_project({"tox.ini": ini})
33+
result = project.run()
34+
result.assert_success()

0 commit comments

Comments
 (0)