Skip to main content

mutation.score_markdown

mutation.score_markdown(report)

The surviving mutants and the mutation score, as Markdown.

Parameters

Name Type Description Default
report ScoreReport The result of mutation_score. required

Returns

Name Type Description
str str A heading, the base commit and whether the working tree was dirty, the versions of Python and pytest, one table row per surviving mutant (the killed ones are only counted) and the line Mutation score: K/N (P %).

Examples

from babregen.mutation import (
    MutantResult, ScoreReport, generate_mutants, score_markdown,
)

mutants = generate_mutants("def f(x):\n    return x + 1\n")
results = (MutantResult(mutants[0], True, "1 failed"),
           MutantResult(mutants[1], False, "survived"))
facts = ("0" * 40, False, "3.14.0", "9.0.0", "0" * 64, 120.0)
print(score_markdown(ScoreReport("pkg.f", "src/pkg/f.py", "0" * 64, ("t.py",), 1, results, *facts)))
# Mutation score: pkg.f

1 evaluations in t.py, 2 mutants.

Base commit `0000000000000000000000000000000000000000`, working tree clean; Python 3.14.0, pytest 9.0.0.

## Surviving mutants

| mutant | line | operator | original | mutated |
|---|---:|---|---|---|
| M002 | 2 | operator | `x + 1` | `x - 1` |

Mutation score: 1/2 (50 %).