judge.evaluate(worktree, tests, python, source_dir, timeout)
Run tests like run_pytest, counting a timeout as one error.
Parameters
| worktree |
Path |
Directory to run in. |
required |
| tests |
Sequence[str] |
Test paths relative to worktree. |
required |
| python |
Path |
Interpreter to run pytest with. |
required |
| source_dir |
str |
Directory (relative to worktree) that holds the package. |
required |
| timeout |
float |
Seconds the run may take. There is no default. |
required |
Returns
|
tuple[Tally, str] |
tuple[Tally, str]: As run_pytest. A run that exceeds timeout is killed and gives Tally(0, 0, 1) and an output that begins timeout after S s. |
Examples
import sys
from pathlib import Path
from tempfile import TemporaryDirectory
from babregen.judge import evaluate
with TemporaryDirectory() as tmp:
(Path(tmp) / "test_a.py").write_text("def test_a():\n while True:\n pass\n")
tally, out = evaluate(Path(tmp), ["test_a.py"], Path(sys.executable), "src", 1)
print(tally, out.splitlines()[0])
Tally(passed=0, failed=0, errors=1) timeout after 1 s