Skip to main content

judge.run_dependents

judge.run_dependents(worktree, unit, python, original, source_dir, timeout)

Run the unit’s dependents against the module in worktree.

Two kinds of dependents run, each in a fresh interpreter with the environment of run_pytest: every declared consumer of kind code below source_dir is imported, and every live docstring example of the unit’s public names in the original module is executed, so the documentation is checked against the replacement.

Parameters

Name Type Description Default
worktree Path Directory to run in; the candidate is already in place. required
unit Unit The unit. required
python Path Interpreter to run with. required
original str Text of the original module at the base commit. required
source_dir str Directory (relative to worktree) that holds the package. required
timeout float Seconds each dependent may take; one that exceeds it is killed and counts as failed. There is no default. required

Returns

Name Type Description
tuple[Tally, str] tuple[Tally, str]: Passed and failed dependents (errors is always 0) and a log with one PASS/FAIL line per dependent, followed by the end of the error output of a failure.

Examples

import sys
from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen import load_spec, make_sample_repo
from spotregen.judge import run_dependents

with TemporaryDirectory() as tmp:
    root = make_sample_repo(Path(tmp) / "demo")
    unit = load_spec(root).units["samplepkg.core.calc"]
    original = (root / unit.path).read_text()
    print(run_dependents(root, unit, Path(sys.executable), original, "src", 60)[0])
Tally(passed=1, failed=0, errors=0)