Repository navigation
Fix obsolete test names never being removed from the stats file - #569
Merged
Merged
Conversation
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
clear_out_obsolete_test_names only pruned tests_by_mangled_function_name, so node IDs of deleted or moved tests stayed in duration_by_test in mutants/mutmut-stats.json for good. Prune both structures from one set of obsolete names, and report that set's size, which is what the message "Removed N obsolete test names" says.
nicklafleur
approved these changes
Sep 8, 2026
nicklafleur
left a comment
Collaborator
There was a problem hiding this comment.
nice, I closed the other PR, we'll merge just this, in the future feel free to just combine the fixes for something like this.
Just rework the title and message a bit to reflect both fixes, thanks
nicklafleur
reviewed
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #564. Replaces #568, whose commit is the first of the two here.
clear_out_obsolete_test_namesis meant to drop the node IDs of deleted orrenamed tests from
mutants/mutmut-stats.json. It never did, for two reasons:count_beforeandcount_afteriterated the keys oftests_by_mangled_function_name, so they summed the lengths of the manglednames rather than the sizes of the test sets. The comprehension in between
keeps every key, so the two sums were always equal, the "Removed N obsolete
test names" message never printed and
save_stats()never ran.tests_by_mangled_function_name. Obsoletenode IDs in
duration_by_testwere never touched and stayed in the file forgood.
Both come off one computation now: obsolete names are everything the stats file
knows minus what the collection run found. Both structures are pruned with that
set, and its size is what the message reports, which is what it says.
new_tests()is unaffected: it only looks at what is in the collection resultbut not in the stats, and this removes nothing from the former.
The tests drive the real
save_stats()into a tmp dir and check that bothstructures reach the file pruned, plus the no-op case.