{"id":5333,"library":"mutmut","title":"Mutmut","description":"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.","status":"active","version":"3.5.0","language":"en","source_language":"en","source_url":"https://github.com/boxed/mutmut","tags":["mutation testing","testing","quality assurance","developer tool"],"install":[{"cmd":"pip install mutmut","lang":"bash","label":"Install Mutmut"}],"dependencies":[{"reason":"Used for parsing and transforming Python code. May require Rust toolchain if prebuilt binaries are unavailable for your architecture.","package":"libcst","optional":false}],"imports":[{"note":"Mutmut is primarily a command-line interface tool and does not expose a typical public Python API for direct programmatic import and use by end-users. Interaction is via shell commands.","symbol":"mutmut CLI","correct":"mutmut run"}],"quickstart":{"code":"# 1. Install mutmut\n# pip install mutmut\n\n# 2. Navigate to your project directory\n# cd your_project\n\n# 3. (Optional) Configure mutmut via setup.cfg for specific paths or test runners\n# [mutmut]\n# paths_to_mutate=src/\n# runner=python -m unittest discover tests \"*_test.py\"\n# tests_dir=tests/\n\n# 4. Run mutation tests\nprint('Running mutmut run (simulated)')\n# mutmut run\n\n# 5. Browse results (interactive UI)\nprint('Running mutmut browse (simulated)')\n# mutmut browse\n\n# 6. View a non-interactive summary of results\nprint('Running mutmut results (simulated)')\n# mutmut results\n\n# 7. Show a specific mutation (e.g., mutant ID 4)\nprint('Running mutmut show 4 (simulated)')\n# mutmut show 4","lang":"bash","description":"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`."},"warnings":[{"fix":"Use WSL for running Mutmut on Windows environments.","message":"Mutmut requires a system with `fork` support. On Windows, it must be run inside WSL (Windows Subsystem for Linux).","severity":"gotcha","affected_versions":"3.x"},{"fix":"For mutating global scope code, consider using Mutmut 2.x, or restructure your code to be within functions if possible for Mutmut 3.x. Check the official documentation for compatibility.","message":"Mutmut 3+ has a different execution model compared to Mutmut 2. If you need to mutate code outside of functions (e.g., global scope code), you might need to use Mutmut 2.","severity":"breaking","affected_versions":"3.x (compared to 2.x)"},{"fix":"Commit your changes before running `mutmut apply` to easily revert if the applied mutation breaks something or is not desired.","message":"When using `mutmut apply <mutant_id>` to write a mutant to disk, *always* ensure your code is under source control and committed before applying, as this modifies your source files.","severity":"gotcha","affected_versions":"All"},{"fix":"Be aware that these specific constructs might not be fully covered by mutation testing when type checker filtering is enabled. You may need to manually inspect them or adjust filtering if you suspect gaps.","message":"Mutmut may have issues mutating enums, staticmethods, and classmethods in a type-safe way when filtering with type checkers like MyPy or PyreFly. These might be skipped or lead to invalid mutants.","severity":"gotcha","affected_versions":"3.x"},{"fix":"Configure `paths_to_mutate` and `tests_dir` in a `setup.cfg` file to explicitly tell Mutmut where your source code and tests are located.","message":"Mutmut may not automatically detect your project's source or test directories. It often defaults to 'tests' or 'test' folders and attempts to figure out code to mutate. For complex layouts, explicit configuration is needed.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}