Skip to content

Commit

Permalink
Fix plain section shadows env config
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Dec 17, 2022
1 parent 9553e4f commit e8cbefa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/changelog/2636.bugfix.rst
@@ -0,0 +1,2 @@
A plain section in INI configuration matching a tox environment name shadowed the laters configuration - by
:user:`gaborbernat`.
2 changes: 1 addition & 1 deletion src/tox/config/source/ini.py
Expand Up @@ -85,8 +85,8 @@ def register_factors(envs: Iterable[str]) -> None:
for section in self.sections():
register_factors(section.names)
for name in section.names:
self._section_mapping[name].append(section.key)
if section.is_test_env:
self._section_mapping[name].append(section.key)
yield name
# add all conditional markers that are not part of the explicitly defined sections
for section in self.sections():
Expand Down
13 changes: 13 additions & 0 deletions tests/session/cmd/test_show_config.py
Expand Up @@ -233,3 +233,16 @@ def test_show_config_core_host_python(tox_project: ToxProjectCreator) -> None:
outcome = project.run("c", "--core", "-e", "py", "-k", "host_python")
outcome.assert_success()
assert f"host_python = {sys.executable}" in outcome.out


def test_show_config_matching_env_section(tox_project: ToxProjectCreator) -> None:
ini = """
[a]
[testenv:a]
deps = c>=1
[testenv:b]
deps = {[testenv:a]deps}"""
project = tox_project({"tox.ini": ini})
outcome = project.run("c", "-e", "a,b", "-k", "deps")
outcome.assert_success()
assert outcome.out.count("c>=1") == 2, outcome.out

0 comments on commit e8cbefa

Please sign in to comment.