From scripts to reliable tools / CORE PATH
Tests that catch a broken contract
Use examples and failure cases to protect meaningful behavior.
Reconciliation checks become executable tests.
Understand the idea
Choose tests that would catch a meaningful defect: a multiplied join, a lost zero, a conflicting key or a missing transaction rollback. A test that merely repeats the implementation’s calculation is weak evidence.
Keep network and clock behavior injectable. Use a temporary directory or database for I/O tests, then add a focused end-to-end fixture check that reconciles the exported result.
What to learn
- Run the stdlib unit tests before adding a dependency.
- Use pytest later for fixtures and parametrization.
- Test malformed input, duplicates, empty data and reruns.
Practice on your own data
Add a regression test for a defect you introduce in a working copy.
Practice this lesson in the Python lab →
The test fails with the defect and passes after a targeted repair.
Prerequisites
Testing & debugging · Files, CSV, JSON & paths
Sources and further reading
- pytest · getting started ↗Official documentation
- Harvard CS50P · lectures & problem sets ↗User-selected HarvardX CS50P course
Track progress on this topic → · Markdown source ↗