measures.unit_measures

measures.unit_measures(spec, name)

Measure the intent coverage and the specification size of one unit.

Parameters

Name Type Description Default
spec RegenSpec The loaded spec. required
name str | Unit The unit, as a dotted module name, its unique suffix ("core.calc") or a spotregen.Unit. required

Returns

Name Type Description
UnitMeasures UnitMeasures The counts. Files that do not exist count zero lines; the check reports them (UNIT01, EVAL01, PROV01).

Raises

Name Type Description
KeyError If name matches no unit or more than one.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen import load_spec, make_sample_repo, unit_measures

with TemporaryDirectory() as tmp:
    spec = load_spec(make_sample_repo(Path(tmp) / "demo"))
    print(unit_measures(spec, "core.calc"))
UnitMeasures(unit='samplepkg.core.calc', intent_items=1, covered_items=1, implementation_lines=10, unit_record_lines=26, decision_lines=9, evaluation_lines=9)