Skip to content

Fix clear_out_obsolete_test_names never persisting its cleanup - #568

Closed
t-roi33 wants to merge 1 commit into
boxed:mainfrom
t-roi33:fix-clear-out-obsolete-test-names
Closed

t-roi33 wants to merge 1 commit into
boxed:mainfrom
t-roi33:fix-clear-out-obsolete-test-names

Conversation

@t-roi33

@t-roi33 t-roi33 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #564.

count_before and count_after in ListAllTestsResult.clear_out_obsolete_test_names iterated the keys of tests_by_mangled_function_name, so they summed the lengths of the mangled names rather than the sizes of the test sets. Since the comprehension in between keeps every key, the two sums were always equal, the "Removed N obsolete test names" message never printed and save_stats() never ran from here. The in-memory filtering worked, but obsolete node IDs stayed in mutants/mutmut-stats.json forever.

This counts the test sets instead and adds a unit test that drives the real save_stats() into a tmp dir and checks the cleanup reaches the file (plus one for the no-op case). The code moved from __main__.py to runners/harness.py in #561, but is otherwise unchanged from the issue.

The before/after counters iterated the keys of
tests_by_mangled_function_name, so they measured the length of each
mangled function name instead of the size of its test set. The dict
comprehension between them keeps every key, so both sums were always
equal, the "Removed N obsolete test names" message never printed and
save_stats() never ran from here. Obsolete node IDs therefore stayed in
mutants/mutmut-stats.json indefinitely, even though the in-memory
filtering worked.

Count the test sets instead, and add a unit test that checks the
cleanup reaches the stats file.

Fixes #564
@nicklafleur

Copy link
Copy Markdown
Collaborator

we'll merge with #569

@nicklafleur nicklafleur closed this Sep 8, 2026
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.

clear_out_obsolete_test_names never persists its cleanup: counters iterate keys instead of values

2 participants