"""Replay the published checker and compare the complete finite example data.""" import json from pathlib import Path from shutil import copyfile import subprocess import sys from tempfile import TemporaryDirectory HERE = Path(__file__).resolve().parent def main(): with TemporaryDirectory() as directory: work = Path(directory) script = work / "verify_count_examples.py" copyfile(HERE / script.name, script) subprocess.run([sys.executable, "-B", str(script)], cwd=work, check=True) results = json.loads((work / "count-examples.json").read_bytes()) # The repository checker also writes a local build identifier. del results["script_sha256"] computed = (json.dumps(results, indent=2) + "\n").encode("utf-8") expected = (HERE / "expected" / "count-examples.json").read_bytes() if computed != expected: raise SystemExit("The regenerated report differs from the archived expectation.") (HERE / "count-examples.json").write_bytes(computed) print("The regenerated example report matches the archived expectation.") if __name__ == "__main__": main()