Skip to content

Match wildcard mutant patterns against function keys in tests_for_mutant_names - #659

Merged
boxed merged 1 commit into
boxed:mainfrom
chenyangsu:fix/wildcard-mutant-clean-tests
Dec 2, 2026
Merged

boxed merged 1 commit into
boxed:mainfrom
chenyangsu:fix/wildcard-mutant-clean-tests

Conversation

@chenyangsu

Copy link
Copy Markdown
Contributor

tests_for_mutant_names(["pkg.mod.x_foo__mutmut_*"]) returns set() because tests_by_mangled_function_name is keyed by function name (pkg.mod.x_foo), which fnmatch against the __mutmut_* pattern never matches. During mutmut run, that empty set causes the clean-test check to run the entire suite, and ? or [...] globs without * raise AssertionError in mangled_name_from_mutant_name.

Stripping the __mutmut_ suffix before fnmatch and checking all glob metacharacters (*, ?, [) matches the function keys directly. Happy to also fall back to matching against the collected mutant list if you prefer.

Testing: pytest tests/test_tests_for_mutant_names.py tests/test_check_associations.py tests/test_test_file_change_flow.py -> 16 passed (4 new cases fail on main). ruff check, ruff format --check, and mypy src passed.

Fixes #592

@boxed
boxed merged commit d7934d6 into boxed:main Dec 2, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run with a name__mutmut_* pattern runs the whole test suite in the clean-test check

2 participants