Skip to content

Commit

Permalink
Fix multiple substitution on factor filtering (#2680)
Browse files Browse the repository at this point in the history
Resolves #2650
  • Loading branch information
gaborbernat committed Dec 11, 2022
1 parent 900d90e commit 3a54b53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/2650.bugfix.rst
@@ -0,0 +1,2 @@
Fix multiple substitution on factor filtering in ``tox.ini`` when multiple factor filters match
- by :user:`gaborbernat`.
1 change: 1 addition & 0 deletions src/tox/config/loader/ini/factor.py
Expand Up @@ -21,6 +21,7 @@ def filter_for_env(value: str, name: str | None) -> str:
for group in factors:
if all((a_name in current) ^ negate for a_name, negate in group):
overall.append(content)
break # if any match we use it, and then bail
result = "\n".join(overall)
return result

Expand Down
8 changes: 8 additions & 0 deletions tests/config/loader/ini/test_factor.py
Expand Up @@ -203,3 +203,11 @@ def test_generative_section_name(tox_ini_conf: ToxIniCreator) -> None:
env_config.add_config(keys="deps-x", of_type=List[str], default=[], desc="deps")
deps = env_config["deps-x"]
assert deps == ["flake8"]


def test_multiple_factor_match(tox_ini_conf: ToxIniCreator) -> None:
config = tox_ini_conf("[testenv]\nconf = a{,-b}: x")
env_config = config.get_env("a-b")
env_config.add_config(keys="conf", of_type=str, default="", desc="conf")
deps = env_config["conf"]
assert deps == "x"

0 comments on commit 3a54b53

Please sign in to comment.