Skip to content

Commit 3a54b53

Browse files
authored
Fix multiple substitution on factor filtering (#2680)
Resolves #2650
1 parent 900d90e commit 3a54b53

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/changelog/2650.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix multiple substitution on factor filtering in ``tox.ini`` when multiple factor filters match
2+
- by :user:`gaborbernat`.

src/tox/config/loader/ini/factor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def filter_for_env(value: str, name: str | None) -> str:
2121
for group in factors:
2222
if all((a_name in current) ^ negate for a_name, negate in group):
2323
overall.append(content)
24+
break # if any match we use it, and then bail
2425
result = "\n".join(overall)
2526
return result
2627

tests/config/loader/ini/test_factor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,11 @@ def test_generative_section_name(tox_ini_conf: ToxIniCreator) -> None:
203203
env_config.add_config(keys="deps-x", of_type=List[str], default=[], desc="deps")
204204
deps = env_config["deps-x"]
205205
assert deps == ["flake8"]
206+
207+
208+
def test_multiple_factor_match(tox_ini_conf: ToxIniCreator) -> None:
209+
config = tox_ini_conf("[testenv]\nconf = a{,-b}: x")
210+
env_config = config.get_env("a-b")
211+
env_config.add_config(keys="conf", of_type=str, default="", desc="conf")
212+
deps = env_config["conf"]
213+
assert deps == "x"

0 commit comments

Comments
 (0)