python-mutation-testing

Introduces deliberate code mutations to measure Python test suite effectiveness.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill python-mutation-testing-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-mutation-testing
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/python/mutation-testing
Command: npx skills add https://github.com/asarchami/dotfiles --skill python-mutation-testing-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Passing tests do not prove a test suite actually catches bugs. This Skill reveals hidden gaps in test coverage by introducing small deliberate bugs (mutations) into Python source code and checking whether any test fails, exposing weak spots that line coverage metrics miss. ## Core Features & Use Cases - Systematic Mutation Catalogue: Applies 8 proven mutation types including negated conditions, changed boundaries, swapped return values, and deleted side effects. - Mutation Score Reporting: Produces a summary table with killed/survived results, a mutation score percentage, and diagnostic quality ratings for each failure. - Test Recommendations: For every survived mutation, describes a concrete test that would catch it, and can optionally implement the missing tests. - Use Case: Before shipping a critical payment module, run mutation testing on it to discover that your tests never verify the boundary condition on the discount calculation, then add the recommended test. ## Quick Start Ask the AI to run mutation testing on a specific Python file or directory to assess how strong its test suite really is.

Frequently Asked Questions about python-mutation-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run mutation testing on a Python project?

Mutation testing introduces small deliberate bugs into source code one at a time and runs the test suite after each change. A mutation is killed if a test fails and survived if all tests pass, revealing gaps in your test suite.

What is a good mutation testing score for pytest?

The mutation score is killed mutations divided by total mutations, such as 6/8 = 75%. Higher scores indicate stronger tests; each survived mutation represents a behavior change your tests cannot detect and should prompt a new test.

Does mutation testing work with pytest test suites?

Yes, the workflow detects pytest via pytest.ini, pyproject.toml configuration, or a tests directory. It confirms the suite passes before starting and runs it after each mutation to record killed or survived results.

What types of code mutations are used in mutation testing?

Common mutations include negating conditions, changing comparison boundaries, swapping return values, deleting side effects or guard clauses, changing arithmetic operators, modifying default arguments, and swapping argument order in non-commutative calls.

Why does mutation testing require a clean git working tree?

A clean working tree ensures mutations can be safely reverted with git checkout after each test run. Uncommitted changes would be lost or mixed with mutations, so you must commit or stash before starting.

What are the limitations of mutation testing?

Mutation testing only mutates production code, never test files, imports, type annotations, or docstrings. It applies 3-8 mutations per file for quality over quantity, so it samples behavior rather than exhaustively testing every possible change.