Skip to content

mutmut v3 copies source to temp dir, breaking editable-install imports #486

@dirkenglund

Description

@dirkenglund

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:

  1. pip install -e .
  2. pytest tests/ — passes
  3. mutmut run --paths-to-mutate src/my_project/core.py
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions