Skip to content

pytestmut

pytestmut pytestmut

Find the bugs your tests would miss.

pytestmut makes small, deliberate mistakes in your code and runs your pytest suite against each one. Every mistake that slips through comes back with the test that would catch it.

Get started Use it with a coding agent GitHub

$ pytestmut run
  src/shop/pricing.py:8  cmp.boundary  [7bf19b971895]  in discount
      - if amount > 100 and loyal:
      + if amount >= 100 and loyal:
      Changing `>` -> `>=` at src/shop/pricing.py:8 in `discount` went unnoticed. Tests
      that ran this code and still passed: tests/test_pricing.py::test_discount. No test
      sits on the boundary of `>`. Add a case where both sides are equal and assert the
      result; ...

Line coverage tells you which code your tests run. Mutation testing tells you which code your tests check.

Why pytestmut

  • Correct results first


    A mutant only counts as caught when a test that normally passes fails with it active. Crashes, flaky tests and slow machines never count.

  • Safe to run anywhere


    Your files are never modified. Test processes are contained, cleaned up and held to a memory budget, and credentials are kept out of their reach.

  • Fast enough for every day


    Each mutant runs only the tests that reach it, in parallel, and verdicts are cached between runs.

  • Strict where it matters


    Give critical code its own thresholds, mutation types and rules for exceptions.

    Policies

  • Built for review


    Every missed mutant says what changed, which tests ran it, and what test would catch it, for people and coding agents alike.

    Coding agents

  • Fits your workflow


    Terminal, pre-commit, CI, pytest --mutate, or an HTML report in your docs site.

    CI/CD

Find your way

Requirements

  • Python 3.10 or newer, pytest 8 or newer.
  • Your project's tests must import your source files directly: an editable install (uv sync, pip install -e .) or a layout pytest can import, such as pythonpath = ["src"].
  • Linux, macOS and Windows, with Python 3.10 to 3.14: the full test suite runs on each in CI.