返回 DeepSeek-Reasonix
verify.sh
1 #!/usr/bin/env bash
2 set -e
3 export PYTHONPYCACHEPREFIX="$(mktemp -d)"
4 python3 - <<'PY'
5 import inspect
6 import json
7 import tempfile
8
9 import report
10
11 stats = report.summarize([1, 2, 3])
12 assert stats == {"count": 3, "total": 6, "mean": 2.0, "max": 3}, stats
13 assert report.summarize([]) == {"count": 0, "total": 0, "mean": 0, "max": None}
14 assert report.summarize([1, 2, 3]) == stats, "summarize must be pure"
15 src = inspect.getsource(report.summarize)
16 assert "open(" not in src, "summarize must not touch files"
17
18 with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as f:
19 path = f.name
20 report.write_report(path, [1, 2, 3])
21 with open(path) as f:
22 assert json.load(f) == {"count": 3, "total": 6, "mean": 2.0, "max": 3}
23 assert "summarize(" in inspect.getsource(report.write_report)
24 PY
25
25 lines BASH