| 1 | #!/usr/bin/env bash |
| 2 | set -e |
| 3 | # Fresh bytecode cache: macOS system Python caches centrally (pycache_prefix), |
| 4 | # where a same-size same-second edit is invisible; a throwaway prefix defeats it. |
| 5 | export PYTHONPYCACHEPREFIX="$(mktemp -d)" |
| 6 | find . -name '__pycache__' -type d -prune -exec rm -rf {} + |
| 7 | python3 - <<'EOF' |
| 8 | import tempfile |
| 9 | |
| 10 | from reader import load |
| 11 | from writer import dump |
| 12 | |
| 13 | records = [("ann", 3), ("bo", 5), ("cyrus", 0)] |
| 14 | with tempfile.NamedTemporaryFile(suffix=".txt", delete=False) as f: |
| 15 | path = f.name |
| 16 | dump(records, path) |
| 17 | assert load(path) == records, load(path) |
| 18 | |
| 19 | dump([], path) |
| 20 | assert load(path) == [] |
| 21 | EOF |
| 22 |