feat(py-doctest): Python tests are doctests on the API they test
Docs go stale, and a test is often the clearest statement of what code does; a doctest is both. Setup goes in private helpers in the module (a `_MockIO` named after `main`'s parameters, `_shown()` to sort), so each example is a call and its output. A script's module docstring is its manual and runs `main(...)` with fakes; otherwise the module docstring stays brief, per docs-files-api. The rule had lived only in one workspace's project memory. It came from qtrx, where agents kept copying test_bld_balance.py: "test_bld_balance is a bad precedent. I keep running into that." Hence the trigger on being about to write a test_*.py, and lazy-tdd's step 1 now points here, since "the project's existing framework and style" is what sent agents to the neighboring file. The example script's doctests pass under several PYTHONHASHSEEDs. Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
6adb4bce33
commit
5c477151cc
3 files changed
+89
-1
No files matched your search
@@ -28,6 +28,8 @@ Code](https://code.claude.com/docs/en/skills) and
|
||||
failure path leaves a trace in the logs.
|
||||
- [lazy-tdd](lazy-tdd/SKILL.md) — works the first time? fine. Goofed?
|
||||
You owe a test.
|
||||
- [py-doctest](py-doctest/SKILL.md) — Python tests are doctests on the
|
||||
API they test, setup in private helpers, no `test_*.py`.
|
||||
- [refactor-mercilessly](refactor-mercilessly/SKILL.md) — at each
|
||||
green, move logic out of the modules that hold authority into small,
|
||||
fast-tested ones; keep refactors in commits of their own.
|
||||
|
||||
Reference in new issue
Block a user