Description
When using mutmut v3 (3.5.0) on a project installed with pip install -e ., mutations fail because mutmut copies source files to a temporary directory where the editable package's import paths no longer resolve.
Reproduction
Project structure:
my-project/
├── pyproject.toml # [project] name = "my_project"
├── src/
│ └── my_project/
│ ├── __init__.py
│ └── core.py # file to mutate
└── tests/
└── test_core.py # imports my_project.core
Steps:
pip install -e .
pytest tests/ — passes
mutmut run --paths-to-mutate src/my_project/core.py
- Mutations fail with
ModuleNotFoundError: No module named 'my_project'
Expected behavior
Mutations should run in-place (or with sys.path adjusted) so that editable installs and relative imports continue to work.
Actual behavior
mutmut copies files to /tmp/ (or a mutants/ directory), then runs pytest from that context. The editable install's .pth file points to the original src/ directory, so the mutated code is never imported — or worse, the original un-mutated code is imported instead, producing false "survived" results.
Workaround
Manual mutation testing via subprocess + file patching (mutate in-place, run tests, restore original).
Related
Environment
- mutmut 3.5.0 (pip reports 2.4.5,
mutmut.__version__ reports 3.5.0)
- Python 3.11.9
- macOS 14 (arm64)
- Project uses
src/ layout with pyproject.toml
Description
When using mutmut v3 (3.5.0) on a project installed with
pip install -e ., mutations fail because mutmut copies source files to a temporary directory where the editable package's import paths no longer resolve.Reproduction
Project structure:
Steps:
pip install -e .pytest tests/— passesmutmut run --paths-to-mutate src/my_project/core.pyModuleNotFoundError: No module named 'my_project'Expected behavior
Mutations should run in-place (or with sys.path adjusted) so that editable installs and relative imports continue to work.
Actual behavior
mutmut copies files to
/tmp/(or amutants/directory), then runs pytest from that context. The editable install's.pthfile points to the originalsrc/directory, so the mutated code is never imported — or worse, the original un-mutated code is imported instead, producing false "survived" results.Workaround
Manual mutation testing via subprocess + file patching (mutate in-place, run tests, restore original).
Related
Environment
mutmut.__version__reports 3.5.0)src/layout with pyproject.toml