Repository navigation
test: cover six behaviours found untested by mutation testing - #502
Merged
tomschr merged 3 commits intoOct 28, 2026
Merged
Conversation
Rule-chosen mutation testing (every comparison, and/or, not, +/-, small
integer and True constant mutated once) left 13 of 171 mutants alive in
src/semver. Eight were real gaps in the tests, not bugs in the code:
- match(): '>=' and '<=' at the boundary version itself
- is_compatible(): build metadata is ignored, also for major 0
- bump_prerelease(): a numeric-only prerelease ('1.2.3-3' -> '1.2.3-4')
- pysemver: the documented return code 2 for an invalid version
- deprecated(): the 'remove' text and the fallback replacement name
All new tests pass on the current code; each one fails on the mutant it
was written for. Result: 166 of 171 mutants killed. The 5 left are 4
equivalent mutants and 1 branch that only runs with the optional native
backend.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVoYLxzt9tSTXTixH9zACY
Member
|
@coresystemdev23 Thank you very much for this overview and the tests! Use the news fragment |
tomschr
approved these changes
Oct 28, 2026
tomschr
left a comment
Member
There was a problem hiding this comment.
Thank you very much for your contribution, @coresystemdev23! 👍
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.
I ran a rule-chosen mutation pass over
src/semver: every comparison,and/or,not,+/-, small integer andTrueconstant was changed once, and the full test suite (including the doctests) was run against each change. 158 of 171 mutants were caught. Of the 13 that survived, 8 point at behaviour the tests did not pin down. The code is correct in every case; this PR only adds tests.">=": (0, 1)->(1, 1)inmatch()match("2.3.7", ">=2.3.7")isTrue"<=": (-1, 0)->(-1, 1)inmatch()match("2.3.8", "<=2.3.7")isFalseself[:4] != other[:4]->[:5](both sides) inis_compatible()if match.group(1)->group(2)in_increment_prerelease()1.2.3-3bumps to1.2.3-4return 2->return 3incli.main()docs/pysemver.rstif not remove->if removeindeprecated()removetext replaces the default sentencereplace or f->replace and findeprecated()replace, the message names the functionAfter this PR: 166 of 171 mutants are caught. The remaining 5, for review:
version.py:190,(1, 0, identifier)->(2, 0, ...)and(1, 1, ...): equivalent. The key is only compared with(0, ...)keys or with keys of the same shape, so the order never changes.version.py:572and:585,candidate > version->>=: equivalent.candidatealways has a different prerelease thanversion(rc3->rc4;<token>.1is excluded by thestartswith(token + ".")check), so they never compare equal.version.py:764: the native-backend branch, already marked# pragma: no cover; it only runs when the optional backend is installed.Notes:
2because the docs show it; if you prefer to keep the contract at "non-zero", it can be relaxed to!= 0.master).changelog.d/pr<NUMBER>.trivial.rstentry once the PR number exists, if you want one for test-only changes.