返回 DeepSeek-Reasonix
verify.sh
1 #!/usr/bin/env bash
2 set -e
3 export PYTHONPYCACHEPREFIX="$(mktemp -d)"
4 python3 - <<'PY'
5 import json
6 import tempfile
7
8 from config import load
9
10
11 def write(cfg):
12 f = tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False)
13 json.dump(cfg, f)
14 f.close()
15 return f.name
16
17
18 good = load(write({"host": "example.test", "port": 8443}))
19 assert good["host"] == "example.test" and good["port"] == 8443
20
21 for bad in ({"host": "example.test"}, {"host": "example.test", "port": "8443"}):
22 try:
23 load(write(bad))
24 except Exception as err:
25 assert "port" in str(err), f"error must name the offending key: {err!r}"
26 else:
27 raise AssertionError(f"broken config accepted: {bad}")
28 PY
29
29 lines BASH