From e8cbefa6921d0482738ac0cd7c5e030d14479a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Sat, 17 Dec 2022 11:18:57 -0800 Subject: [PATCH] Fix plain section shadows env config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- docs/changelog/2636.bugfix.rst | 2 ++ src/tox/config/source/ini.py | 2 +- tests/session/cmd/test_show_config.py | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/2636.bugfix.rst diff --git a/docs/changelog/2636.bugfix.rst b/docs/changelog/2636.bugfix.rst new file mode 100644 index 0000000000..3362adb050 --- /dev/null +++ b/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`. diff --git a/src/tox/config/source/ini.py b/src/tox/config/source/ini.py index d28ae083fc..ee3ed77c03 100644 --- a/src/tox/config/source/ini.py +++ b/src/tox/config/source/ini.py @@ -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(): diff --git a/tests/session/cmd/test_show_config.py b/tests/session/cmd/test_show_config.py index d4fa3b3783..33c4fc487e 100644 --- a/tests/session/cmd/test_show_config.py +++ b/tests/session/cmd/test_show_config.py @@ -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