Skip to main content

Mutation testing for Python with an embedded-in-source manifest

Project description

mutate4py

Mutation testing for Python. Discovers mutation sites, applies each one, runs your tests, and reports killed, survived, and uncovered mutations — with an embedded-in-source manifest so differential reruns survive a clone with zero CI setup.

A faithful Python port of unclebob/mutate4go, with the user-facing contract cross-checked against unclebob/clj-mutate. Where Python forces a divergence (coverage acquisition, the manifest hash) it is marked [PY] and justified in docs/spec.md.

Install

uvx mutate4py        # run without installing
uv tool install mutate4py

Usage

mutate4py path/to/file.py --test-command "pytest" --lcov lcov.info

Generate lcov.info with coverage.py:

pytest --cov --cov-branch --cov-report=lcov:lcov.info

See mutate4py --help and the spec for the full flag set.

How it differs from mutate4go ([PY])

  • --max-workers uses clone-per-worker, not tree-copy+cwd — mutate4go's tree-copy model is unsound under Python editable installs (pip install -e .), so each worker gets its own uv-provisioned venv instead.
  • Coverage is acquired explicitly--lcov / --cov-cmd / --reuse-coverage (Python has no universal -coverprofile equivalent).
  • Manifest hash is structural (ast.dump()), so reformatting and comment edits don't trigger a re-test, but any behavior-affecting edit does.
  • Operators are localized to Python: adds and/or, True/False, and the identity/membership negation flips is/is not and in/not in.

Develop

Python ≥ 3.10, stdlib ast (zero runtime deps), packaged with hatchling.

uv sync
uv run mutate4py --help
uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mutate4py-0.1.0.tar.gz (301.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mutate4py-0.1.0-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file mutate4py-0.1.0.tar.gz.

File metadata

  • Download URL: mutate4py-0.1.0.tar.gz
  • Upload date:
  • Size: 301.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mutate4py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b615b1a8fc82044d8eb1294b19c09c75ba4ecd1600e5823a2c23e3000281e67
MD5 721eaaa9d2295582fcfd92e78693211c
BLAKE2b-256 bd523e3da60d123f7095e78b0a7810dd63d48b90116e47ca7b928f801506d12b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mutate4py-0.1.0.tar.gz:

Publisher: release.yml on gabadi/mutate4py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mutate4py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mutate4py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mutate4py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b799ef7b693be8ec616df3f2ea652766f37a052c4b1de63e25e82c3a2c04b00
MD5 bf960575674329c3969eeabca72d39b2
BLAKE2b-256 6ae1328aa112002e069c34ad4c814adb83d073511fe7c47f6f6d736696fd02b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mutate4py-0.1.0-py3-none-any.whl:

Publisher: release.yml on gabadi/mutate4py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page