Fast mutation testing for Python
Project description
irradiate
Fast mutation testing for Python, written in Rust.
Why
Mutation testing is slow. The bottleneck isn't generating mutants — it's running the test suite once per mutant. A typical pytest startup costs 200-500ms, and with hundreds of mutants that adds up to minutes of pure overhead.
irradiate eliminates this by maintaining a pool of pre-warmed pytest workers. Pytest starts once, collects tests once, then forks a child process for each mutant. The result: mutation testing at 30-60 mutants/sec on real codebases.
How it works
- Parse Python source with tree-sitter (27 mutation operator categories, ~160+ distinct mutations)
- Generate trampolined mutants — each function gets an original, N mutated variants, and a runtime dispatcher
- Collect test coverage and timing in a single pytest run
- Fork a child process per mutant inside pre-warmed workers (no pytest restart)
- Report results as terminal output, JSON (Stryker schema v2), HTML, or GitHub Actions annotations
Install
pip install irradiate
Or build from source:
cargo build --release
Requires Python 3.10+ with pytest installed.
Usage
# Run mutation testing (auto-detects src/ and tests/)
irradiate run
# Only test functions changed since main
irradiate run --diff main
# Generate JSON report (Stryker mutation-testing-report-schema v2)
irradiate run --report json
# Generate self-contained HTML report
irradiate run --report html
# Fail CI if mutation score is below threshold
irradiate run --fail-under 80
# See cached results
irradiate results
# Show diff for a specific mutant
irradiate show module.x_func__irradiate_1
Configuration
Configure via [tool.irradiate] in pyproject.toml:
[tool.irradiate]
paths_to_mutate = "src"
tests_dir = "tests"
do_not_mutate = ["**/generated/*", "**/vendor/*"]
pytest_add_cli_args = ["-x", "--tb=short"]
All settings can be overridden via CLI flags. Run irradiate run --help for the full list.
Features
Mutation operators (27 categories)
Arithmetic, comparison, boolean, augmented assignment, unary, string mutation/emptying, number literals, lambda bodies, return values, assignments, default arguments, argument removal, method swaps, dict kwargs, decorator removal (planned), exception types, match/case removal, condition negation, condition replacement, statement deletion, keyword swap, loop mutation, ternary swap, slice index removal.
Functions can be excluded with # pragma: no mutate.
Execution model
- Fork-per-mutant (default): Workers fork after pytest collection. Each mutant runs in an isolated child process — no state leakage between mutants, no pytest restart overhead.
--isolate: Full subprocess isolation. Slower but guaranteed clean for projects with complex test infrastructure.--verify-survivors: After the main run, re-tests survived mutants in isolate mode to catch false negatives from warm-session state leakage.
Incremental mode (--diff)
Only mutate functions touched by a git diff. Uses git merge-base to compare against the divergence point, so --diff main does the right thing on feature branches.
Reporting
- Terminal: summary table + list of survived mutants
- JSON: Stryker mutation-testing-report-schema v2 — compatible with Stryker Dashboard
- HTML: self-contained report using mutation-testing-elements web component
- GitHub Actions: auto-detected
::warningannotations on survived mutants + Markdown step summary
Caching
Content-addressable cache keyed on SHA-256 of function body + test IDs + operator. Survives rebases, branch switches, and touch — unlike mtime-based caches.
Decorator support
@property, @classmethod, and @staticmethod are handled natively via a descriptor-aware trampoline. Other decorated functions are skipped (source-patching fallback planned — see #13).
Performance tuning
--workers N: control parallelism (defaults to CPU count)--timeout-multiplier N: scale per-mutant timeout (default 10x baseline)--worker-recycle-after N: respawn workers after N mutants (auto-tuned)--max-worker-memory N: recycle workers exceeding N MB RSS--covered-only: skip mutants with no test coverage--no-stats: skip coverage collection, test all mutants against all tests
How it compares to mutmut
| mutmut | irradiate | |
|---|---|---|
| Speed | pytest.main() per mutant (~200ms each) |
Fork-per-mutant — pytest starts once |
| Parser | LibCST (Python) | tree-sitter (Rust, parallel) |
| Operators | ~20 categories | 27 categories |
| Cache | mtime-based | Content-addressable (SHA-256) |
| Orchestration | Python multiprocessing | Rust + tokio async |
| Incremental | — | --diff with merge-base |
| Reports | Terminal only | JSON, HTML, GitHub Actions annotations |
| Decorator support | Skip all | @property/@classmethod/@staticmethod handled |
| CI integration | Manual | --fail-under, GitHub annotations, step summary |
| Isolation | Fork only | Warm-session + --isolate + --verify-survivors |
Acknowledgments
irradiate's trampoline architecture and mutation operator design are informed by mutmut. The naming convention is partially compatible with mutmut to ease migration.
License
MIT
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file irradiate-0.1.1.tar.gz.
File metadata
- Download URL: irradiate-0.1.1.tar.gz
- Upload date:
- Size: 260.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
122e5b98a34f415b484f894fba16fa4d946dec23c5473f72b50ddfdbacdb6e57
|
|
| MD5 |
790168a0694615e50ee479611eb11bc1
|
|
| BLAKE2b-256 |
2949bb029dc296cc86cadfca4aef63c610335b762b5b3744e3581251e643cf81
|
Provenance
The following attestation bundles were made for irradiate-0.1.1.tar.gz:
Publisher:
release.yml on nwyin/irradiate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irradiate-0.1.1.tar.gz -
Subject digest:
122e5b98a34f415b484f894fba16fa4d946dec23c5473f72b50ddfdbacdb6e57 - Sigstore transparency entry: 1156819882
- Sigstore integration time:
-
Permalink:
nwyin/irradiate@db315da0b57416a914d809399ea9f818c530b742 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nwyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db315da0b57416a914d809399ea9f818c530b742 -
Trigger Event:
push
-
Statement type:
File details
Details for the file irradiate-0.1.1-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: irradiate-0.1.1-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e63b09d991279b414d214c63fa8ee6e09056734e1e4025c15ecf7a6cbe600772
|
|
| MD5 |
21e68c9e3238a3adfe781e98a2cadd14
|
|
| BLAKE2b-256 |
0815bc1ba908401889aafa65b8d9bab28955d088c400a604624768fa011bfc8a
|
Provenance
The following attestation bundles were made for irradiate-0.1.1-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on nwyin/irradiate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irradiate-0.1.1-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
e63b09d991279b414d214c63fa8ee6e09056734e1e4025c15ecf7a6cbe600772 - Sigstore transparency entry: 1156820831
- Sigstore integration time:
-
Permalink:
nwyin/irradiate@db315da0b57416a914d809399ea9f818c530b742 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nwyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db315da0b57416a914d809399ea9f818c530b742 -
Trigger Event:
push
-
Statement type:
File details
Details for the file irradiate-0.1.1-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: irradiate-0.1.1-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f95d44678a8901fbe335b118af5a02e304a17203c8a9f37361b6d76fc2fa0a05
|
|
| MD5 |
5e58d8cd1f44c730948dd802d825e8d6
|
|
| BLAKE2b-256 |
a457e763622dab9b4f6ba9683a95e0cda59c1c54222b451fe6ef512712863161
|
Provenance
The following attestation bundles were made for irradiate-0.1.1-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on nwyin/irradiate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irradiate-0.1.1-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
f95d44678a8901fbe335b118af5a02e304a17203c8a9f37361b6d76fc2fa0a05 - Sigstore transparency entry: 1156820271
- Sigstore integration time:
-
Permalink:
nwyin/irradiate@db315da0b57416a914d809399ea9f818c530b742 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nwyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db315da0b57416a914d809399ea9f818c530b742 -
Trigger Event:
push
-
Statement type:
File details
Details for the file irradiate-0.1.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: irradiate-0.1.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00a855d4c32a396e5832e5ea96b047b3aaa69d543532ab12efe2cc30a4591100
|
|
| MD5 |
e8a357ffeaa3f2ffc725551945dbc19f
|
|
| BLAKE2b-256 |
087e97b491f7530cd54784e0695bfc00759da6d27502faadcd065888e2ef2d73
|
Provenance
The following attestation bundles were made for irradiate-0.1.1-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on nwyin/irradiate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irradiate-0.1.1-py3-none-macosx_11_0_arm64.whl -
Subject digest:
00a855d4c32a396e5832e5ea96b047b3aaa69d543532ab12efe2cc30a4591100 - Sigstore transparency entry: 1156821082
- Sigstore integration time:
-
Permalink:
nwyin/irradiate@db315da0b57416a914d809399ea9f818c530b742 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nwyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db315da0b57416a914d809399ea9f818c530b742 -
Trigger Event:
push
-
Statement type:
File details
Details for the file irradiate-0.1.1-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: irradiate-0.1.1-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b25e2dc704cfc53d5f1d28bffd000ec955859de90604761a5f86431476540dcd
|
|
| MD5 |
194123a819297617106b6cce8f7f22d4
|
|
| BLAKE2b-256 |
d94ce0405f93bc68bec5a93d36b7e35378a5c6a0081d5a56c6abb79c85255813
|
Provenance
The following attestation bundles were made for irradiate-0.1.1-py3-none-macosx_10_12_x86_64.whl:
Publisher:
release.yml on nwyin/irradiate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irradiate-0.1.1-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
b25e2dc704cfc53d5f1d28bffd000ec955859de90604761a5f86431476540dcd - Sigstore transparency entry: 1156820511
- Sigstore integration time:
-
Permalink:
nwyin/irradiate@db315da0b57416a914d809399ea9f818c530b742 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nwyin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db315da0b57416a914d809399ea9f818c530b742 -
Trigger Event:
push
-
Statement type: