gui.model.read_score

gui.model.read_score(path)

Read the score.toml that spotregen mutate --out writes.

Parameters

Name Type Description Default
path Path | str The file. required

Returns

Name Type Description
MutationScore | None MutationScore | None: The score, or None if the file does not exist (the run ended before it wrote one).

Raises

Name Type Description
ValueError If the file cannot be read, is not valid TOML or lacks a field.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen.gui.model import read_score

text = (
    'unit = "core.calc"\nplanted = 2\nkilled = 1\nbaseline_passed = 3\n\n'
    '[[mutant]]\nid = "m1"\nline = 3\noperator = "arith"\n'
    'original = "+"\nmutated = "-"\nkilled = false\ndetail = "passed"\n'
)
with TemporaryDirectory() as tmp:
    file = Path(tmp) / "score.toml"
    print(read_score(file))
    file.write_text(text)
    print(read_score(file).summary())
None
core.calc: 1/2 mutants killed
survived: m1 line 3: + -> -