Mutmut

3.5.0 · active · verified Mon Apr 13

Mutmut is a mutation testing system for Python, currently at version 3.5.0. It helps identify weaknesses in test suites by making small, automated changes (mutations) to your code and running your tests against them. If tests still pass after a mutation, it indicates a potential gap in the test coverage. It primarily operates as a command-line tool with a focus on ease of use and incremental workflow.

Warnings

Install

Imports

Quickstart

After installation, navigate to your project root. Run `mutmut run` to execute mutation tests. You can then use `mutmut browse` for an interactive review of mutants, `mutmut results` for a summary, or `mutmut show <id>` to inspect a specific mutation. Configuration can be done in `setup.cfg`.

# 1. Install mutmut
# pip install mutmut

# 2. Navigate to your project directory
# cd your_project

# 3. (Optional) Configure mutmut via setup.cfg for specific paths or test runners
# [mutmut]
# paths_to_mutate=src/
# runner=python -m unittest discover tests "*_test.py"
# tests_dir=tests/

# 4. Run mutation tests
print('Running mutmut run (simulated)')
# mutmut run

# 5. Browse results (interactive UI)
print('Running mutmut browse (simulated)')
# mutmut browse

# 6. View a non-interactive summary of results
print('Running mutmut results (simulated)')
# mutmut results

# 7. Show a specific mutation (e.g., mutant ID 4)
print('Running mutmut show 4 (simulated)')
# mutmut show 4

view raw JSON →