Skip to content

Commit c504e48

Browse files
authored
fix(config): let empty factor fallbacks override TOML group defaults (tox-dev#4072)
1 parent a5a7ce6 commit c504e48

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

docs/changelog/4072.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Preserve an explicitly empty ``{factor:label:}`` fallback instead of using the declared factor group default.

src/tox/config/loader/replacer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def replace_factor(conf: Config, args: list[str], conf_args: ConfigLoadArgs) ->
334334
for value in group.values:
335335
if value in env_factors:
336336
return value
337-
return default or group.default or ""
337+
return default if len(args) > 1 else group.default or ""
338338

339339

340340
__all__ = [

tests/config/source/test_toml_env_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ def test_env_list_product_labeled_range_factor_group(tox_project: ToxProjectCrea
579579
pytest.param("task-django42", "django42", id="active-factor-wins"),
580580
pytest.param("other", "django50", id="group-default"),
581581
pytest.param("inline", "django42", id="inline-default-wins"),
582+
pytest.param("empty-inline", "", id="empty-inline-default-wins"),
582583
],
583584
)
584585
def test_env_base_factor_group_default(tox_project: ToxProjectCreator, env: str, expected: str) -> None:
@@ -595,6 +596,9 @@ def test_env_base_factor_group_default(tox_project: ToxProjectCreator, env: str,
595596
596597
[env.inline]
597598
description = "Test {factor:django_version:django42}"
599+
600+
[env.empty-inline]
601+
description = "Test {factor:django_version:}"
598602
"""),
599603
})
600604
outcome = project.run("c", "-e", env, "-k", "description")

0 commit comments

Comments
 (0)