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

Python: mutants in an uncovered `elif` condition are run and reported as SURVIVED

Aperta
#9 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, testing

Direzione di ricerca

Start with _covered in src/mutator/engine.py and _statement_line in src/mutator/sites.py, then inspect the tree-sitter parent types for elif_clause, except_clause, and case_clause. Run the provided pytest command with existing coverage to reproduce the line-4 mutants being reported as SURVIVED. Done means those sites are reported as UNCOVERED while the covered line-2 mutant still reports SURVIVED.

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

Descrizione

_covered (src/mutator/engine.py:53) accepts a site when its line or its anchor_line is covered. _statement_line (src/mutator/sites.py:180) climbs to the first *_statement parent; for a site in an elif condition, an except clause or a case guard, that is the enclosing if_statement / try_statement / match_statement, whose first line is covered.

def classify(x):
    if x > 10:
        return "high"
    elif x > 0:
        return "pos"
    return "non-pos"
def test_classify_high():
    assert classify(20) == "high"

LCOV: DA:2,1, DA:4,0, DA:5,0.

mutator --use-existing-coverage --max-workers 2 --test-command ".venv/bin/python -m pytest -q -x tests" src/demo/branches.py
SURVIVED  src/demo/branches.py:2 > -> >=
SURVIVED  src/demo/branches.py:4 > -> >=
SURVIVED  src/demo/branches.py:4 0 -> 1

Expected: both line-4 sites UNCOVERED (line 2 surviving is correct).

The same climb applies to a case guard (anchored to the match line) and, less commonly, to a mutation site inside an except clause (anchored to the try line). I checked this by parsing such code with tree-sitter-python and applying _statement_line. Stopping the climb at elif_clause, except_clause and case_clause would fix it.

Environment: Linux x86_64, Python 3.11.13, tree-sitter 0.26.0, tree-sitter-language-pack 1.22.1, mutator a5a0cb8 with crapper 6fd92c4.

Lingua principale
Python
Stelle
55
Fork
7
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 unclebob/mutator

Tutte le issue di unclebob/mutator

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.