Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Mutation testing doesn't work with Django app structure - import path issues ?

Aperta
#456 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
django, python

Direzione di ricerca

Inizia riproducendo le due configurazioni dell’issue con la struttura del progetto Django mostrata, quindi esamina setup_source_paths() e la gestione di paths_to_mutate e tests_dir. Confronta la directory di lavoro e i percorsi di importazione di pytest all’interno di mutants/ con il progetto originale; il lavoro è completato quando viene identificata una configurazione supportata oppure il comportamento di risoluzione dei percorsi viene corretto e verificato con la relativa esecuzione della mutazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description
I'm trying to use mutmut with a Django project but running into issues with path resolution and import paths.
Project structure

my_project/
├── kiosk/
│   ├── __init__.py
│   ├── services/
│   │   ├── __init__.py
│   │   └── kiosk_payment_service.py  # Source to mutate
│   └── tests/
│       └── services/
│           └── test_kiosk_payment_service.py  # Tests
├── mutants/  # Created by mutmut
│   └── kiosk/
│       └── services/
│           └── kiosk_payment_service.py  # Mutated code
├── setup.cfg
└── pyproject.toml

Issue 1: File not found with relative path

Configuration:

[mutmut]

paths_to_mutate=kiosk/services/kiosk_payment_service.py

tests_dir=kiosk/tests/services/test_kiosk_payment_service.py

debug=true

Error:

ERROR: file or directory not found: kiosk/tests/services/test_kiosk_payment_service.py

This happens because mutmut runs pytest from inside the mutants/ directory, so kiosk/tests/... doesn't exist there.

Issue 2: Tests pass but mutations not detected

Configuration (using ../ to fix path):

[mutmut]
paths_to_mutate=kiosk/services/kiosk_payment_service.py

tests_dir=../kiosk/tests/services/test_kiosk_payment_service.py

debug=true

Result:

========= 64 passed in 10.75s ==========

exit code 0

Stopping early, because we could not find any test case for any mutant.

It seems that the selected tests do not cover any code that we mutated.

The tests run successfully, but mutmut reports no coverage of mutated code.

What I've tried

  1. Using also_copy to include init.py files — didn't help
  2. Various path configurations — same results

Question

Is there a recommended way to use mutmut with Django projects? Should setup_source_paths() be extended to handle arbitrary paths_to_mutate values?

Environment

  • Python: 3.11
  • mutmut: 3.4.0
  • Django: 4.2
  • OS: macOS
Lingua principale
Python
Stelle
1.5k
Fork
179
Merge medio
1g 18h
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di boxed/mutmut

Tutte le issue di boxed/mutmut

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.