Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

test: cover six behaviours found untested by mutation testing - #502

Merged
tomschr merged 3 commits into
python-semver:masterfrom
coresystemdev23:test/close-mutation-gaps
Oct 28, 2026
Merged

tomschr merged 3 commits into
python-semver:masterfrom
coresystemdev23:test/close-mutation-gaps

Conversation

@coresystemdev23

Copy link
Copy Markdown
Contributor

I ran a rule-chosen mutation pass over src/semver: every comparison, and/or, not, +/-, small integer and True constant 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.

Mutant that survived Behaviour now tested
">=": (0, 1) -> (1, 1) in match() match("2.3.7", ">=2.3.7") is True
"<=": (-1, 0) -> (-1, 1) in match() match("2.3.8", "<=2.3.7") is False
self[:4] != other[:4] -> [:5] (both sides) in is_compatible() build metadata is ignored, also for major 0
if match.group(1) -> group(2) in _increment_prerelease() 1.2.3-3 bumps to 1.2.3-4
return 2 -> return 3 in cli.main() the return code 2 shown in docs/pysemver.rst
if not remove -> if remove in deprecated() the custom remove text replaces the default sentence
replace or f -> replace and f in deprecated() without replace, the message names the function

After 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:572 and :585, candidate > version -> >=: equivalent. candidate always has a different prerelease than version (rc3 -> rc4; <token>.1 is excluded by the startswith(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:

  • The return-code test pins 2 because the docs show it; if you prefer to keep the contract at "non-zero", it can be relaxed to != 0.
  • No new lint findings (ruff and black report the same results as on master).
  • I'll add a changelog.d/pr<NUMBER>.trivial.rst entry once the PR number exists, if you want one for test-only changes.

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
@tomschr

tomschr commented Oct 24, 2026

Copy link
Copy Markdown
Member

@coresystemdev23 Thank you very much for this overview and the tests! Use the news fragment 502.

@tomschr tomschr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution, @coresystemdev23! 👍

@tomschr
tomschr merged commit f3c7138 into python-semver:master Oct 28, 2026
17 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.

2 participants