Skip to main content

Type-aware mutation testing for Python — fast, opinionated, pytest-native

Project description

pytest-leela

Type-aware mutation testing for Python.

PyPI version Python versions License CI


What it does

pytest-leela runs mutation testing inside your existing pytest session. It injects AST mutations via import hooks (no temp files), maps each mutation to only the tests that cover that line, and uses type annotations to skip mutations that can't possibly fail your tests.

It's opinionated: we target latest Python, favour speed over configurability, and integrate with pytest without separate config files or runners. If that fits your workflow, great. MIT licensed — fork it if it doesn't.


Install

pip install pytest-leela

Quick Start

Run mutation testing on your whole test suite:

pytest --leela

Target specific modules (pass --target multiple times):

pytest --leela --target myapp/models.py --target myapp/views.py

Only mutate lines changed vs a branch:

pytest --leela --diff main

Limit CPU cores:

pytest --leela --max-cores 4

Cap memory usage:

pytest --leela --max-memory 4096

Combine flags:

pytest --leela --diff main --max-cores 4 --max-memory 4096

Features

  • Type-aware mutation pruning — uses type annotations to skip mutations that can't possibly trip your tests (e.g. won't swap + to - on a str operand)
  • Per-test coverage mapping — each mutant runs only the tests that exercise its lines, not the whole suite
  • In-process execution via import hooks — mutations applied via sys.meta_path, zero filesystem writes, fast loop
  • Git diff mode--diff <ref> limits mutations to lines changed since that ref
  • Framework-aware — clears Django URL caches between mutants so view reloads work correctly
  • Resource limits--max-cores N caps parallelism; --max-memory MB guards memory

Requirements

  • Python >= 3.12
  • pytest >= 7.0

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

pytest_leela-0.1.0.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

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

pytest_leela-0.1.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest_leela-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4b8fd6ffa7ecc041f3514de4ab121f7659625d46a55667b7f45d4a2dd936c05b
MD5 4a4fd625efbbc0b74db73dce2cb635a1
BLAKE2b-256 70f61aea447e905f6cd17e1f3833a5ae5739a1dddba95cf3be06ea9fe7cc3e8d

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on markng/pytest-leela

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

File details

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

File metadata

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

File hashes

Hashes for pytest_leela-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 727f655e79723dfcfdc855069aa6480f7f64b98fe4a4b97ccc1790f90bb6e93c
MD5 2d1f4a06530a7047b864b90468d3d7af
BLAKE2b-256 318357bcf1056cf5830df4fee746204e61d527732c7e217ceae9a081efdf5d71

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on markng/pytest-leela

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