Skip to main content

mutation.ScoreReport

mutation.ScoreReport(
    unit,
    module,
    module_sha256,
    evaluations,
    baseline_passed,
    results,
    base,
    dirty,
    python,
    pytest,
    packages_sha256,
    timeout_s,
)

Mutation score of one unit.

Attributes

Name Type Description
unit str Dotted module name.
module str Path of the module, relative to the project root.
module_sha256 str SHA-256 of the module file that the mutants were made from.
evaluations tuple[str, …] The evaluation files that were run.
baseline_passed int Evaluations that pass on the unchanged module.
results tuple[MutantResult, …] One result per mutant, in source order.
base str Full SHA of HEAD when the mutants were run.
dirty bool Whether the working tree, which is what is mutated, differed from base.
python str Version of the interpreter that ran pytest.
pytest str Version of pytest in it.
packages_sha256 str SHA-256 of the distributions installed in it, as run.toml records it under [tool].
timeout_s float Seconds one evaluation run could take.

Examples

from babregen.mutation import MutantResult, ScoreReport, generate_mutants

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)
report = ScoreReport("pkg.f", "src/pkg/f.py", "0" * 64, ("tests/test_f.py",), 1, results, *facts)
print(report.killed, report.planted, report.score)
1 2 0.5