summaryrefslogtreecommitdiff
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/config/source/test_source_ini.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/config/source/test_source_ini.py b/tests/config/source/test_source_ini.py
index 5d61290b..12d4eec2 100644
--- a/tests/config/source/test_source_ini.py
+++ b/tests/config/source/test_source_ini.py
@@ -2,7 +2,9 @@ from __future__ import annotations
from pathlib import Path
+from tests.conftest import ToxIniCreator
from tox.config.loader.section import Section
+from tox.config.sets import ConfigSet
from tox.config.source.ini import IniSource
@@ -22,3 +24,27 @@ def test_source_ini_ignore_invalid_factor_filters(tmp_path: Path) -> None:
loader = IniSource(tmp_path, content="[a]\nb= if c: d")
res = list(loader.envs({"env_list": []})) # type: ignore
assert not res
+
+
+def test_source_ini_custom_non_testenv_sections(tox_ini_conf: ToxIniCreator) -> None:
+ """Validate that a plugin can load section with custom prefix overlapping testenv name."""
+
+ class CustomConfigSet(ConfigSet):
+ def register_config(self) -> None:
+ self.add_config(
+ keys=["a"],
+ of_type=str,
+ default="",
+ desc="d",
+ )
+
+ config = tox_ini_conf("[testenv:foo]\n[custom:foo]\na = b")
+ known_envs = list(config._src.envs(config.core))
+ assert known_envs
+ custom_section = config.get_section_config(
+ section=Section("custom", "foo"),
+ base=[],
+ of_type=CustomConfigSet,
+ for_env=None,
+ )
+ assert custom_section["a"] == "b"