casebench
test cases straight onto the board.
git clone https://owenrusk.dev/casebench.git
casebench / tests/helpers.py -rw-r--r-- · 486 bytes
1 import io 2 from contextlib import redirect_stderr, redirect_stdout 3 from pathlib import Path 4 5 from casebench.cli import main 6 from casebench.memstore import MemStore 7 8 UMBRELLA = Path(__file__).parents[1] / "examples" / "lost-umbrella" 9 10 11 def run(store: MemStore, *argv: str) -> tuple[int, str, str]: 12 out, err = io.StringIO(), io.StringIO() 13 with redirect_stdout(out), redirect_stderr(err): 14 code = main(list(argv), store=store) 15 return code, out.getvalue(), err.getvalue()