summaryrefslogtreecommitdiff
path: root/src/tox
diff options
context:
space:
mode:
authorMasen Furer <m_github@0x26.net>2023-02-21 00:13:46 -0800
committerGitHub <noreply@github.com>2023-02-21 00:13:46 -0800
commitf4fcb7b44c1855f5bcc2a352755a081094ecb130 (patch)
treedbfbbc58814a5f600ee42bd191c031b0a914f308 /src/tox
parent23ebd04bc257b407df084ea12c15092da78d976a (diff)
downloadtox-git-f4fcb7b44c1855f5bcc2a352755a081094ecb130.tar.gz
Custom prefix in .ini source (#2927)
* test_source_ini: custom config can overlap testenv regression test for plugin behavior in #2926 * IniSource.get_loader: check section.prefix ensure that loaders returned from .ini source are bound to the correct section prefix, if specified. add comment explaining why the code must look up the name in the _section_mapping fix #2926 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'src/tox')
-rw-r--r--src/tox/config/source/ini.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tox/config/source/ini.py b/src/tox/config/source/ini.py
index df6c2876..fb23c0c3 100644
--- a/src/tox/config/source/ini.py
+++ b/src/tox/config/source/ini.py
@@ -40,8 +40,13 @@ class IniSource(Source):
yield IniSection.from_key(section)
def get_loader(self, section: Section, override_map: OverrideMap) -> IniLoader | None:
- sections = self._section_mapping.get(section.name)
- key = sections[0] if sections else section.key
+ # look up requested section name in the generative testenv mapping to find the real config source
+ for key in self._section_mapping.get(section.name) or []:
+ if section.prefix is None or Section.from_key(key).prefix == section.prefix:
+ break
+ else:
+ # if no matching section/prefix is found, use the requested section key as-is (for custom prefixes)
+ key = section.key
if self._parser.has_section(key):
return IniLoader(
section=section,