Skip to main content

Mutation testing made easy

Project description

🐛 mutation 🐛

early draft requires more testing, please report any findings in my public inbox.

The goal of mutation is to give an idea on how robust, and help improve test suites.

Getting started

pip install mutation
mutation play tests.py --include="foobar/ex.py,foobar/__init__.py" --exclude="tests.py"

Then call:

mutation replay

Usage

mutation play [--verbose] [--exclude=<globs>] [--only-deadcode-detection] [--include=<globs>] [--sampling=<s>] [--randomly-seed=<n>] [--max-workers=<n>] [<file-or-directory> ...] [-- TEST-COMMAND ...]
mutation replay [--verbose] [--max-workers=<n>]
mutation list
mutation show MUTATION
mutation apply MUTATION
mutation (-h | --help)
mutation --version

Both --include and --exclude support glob patterns. They are optional but highly recommended to avoid the production of useless mutations.

mutation will only mutate code that has test coverage, hence it works better with a high coverage.

mutation will detect whether the tests can be run in parallel. It is recommended to make the test suite work in parallel to speed up the work of mutation.

Also, it is better to work with a random seed, otherwise add the option --randomly-seed=n that works.

TODO

  • Avoid mutations that are syntax errors to improve efficiency, use python 3.9+ ast.unparse, possibly with black;
  • mutation play can error even if the code and the test suite is valid e.g. removing a docstring will trigger an error: reduce, and hopefully eliminate that problem, requires python 3.9+ (see above);
  • Add PyPy support;

Links

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

mutation-0.4.8.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

mutation-0.4.8-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file mutation-0.4.8.tar.gz.

File metadata

  • Download URL: mutation-0.4.8.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for mutation-0.4.8.tar.gz
Algorithm Hash digest
SHA256 f72e8c177fc3d302fb57b2a79446c68f0b86e7a760021a7883025def3946d927
MD5 1437240259c0bf6f51e481720ff3e129
BLAKE2b-256 1d756c66877b614e107d5f0ced8443de219a43009c85a4d93cfceaba68ff031d

See more details on using hashes here.

File details

Details for the file mutation-0.4.8-py3-none-any.whl.

File metadata

  • Download URL: mutation-0.4.8-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for mutation-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4fff923d4da644289a9fabddc4972df29d80e3444ab513221e5618da9c5bca16
MD5 8da641bf186541dbc0a12f7bf144a2ec
BLAKE2b-256 190be1a00c73ef0791fb8f30f51935b33e9eb99c7568d14644e253878f94350f

See more details on using hashes here.

Supported by

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