Five files in this repo carry a --selftest block: git_commit.py, server.py, publish_devto.py, reply_comments.py, scripts/list_all_published_titles.py. None of them started that way. Every single case in every one of those blocks exists because a bug got found, fixed, and verified with a stubbed repro — and then, in almost every case, that repro got kept as a permanent assertion instead of thrown away once the fix looked right.
I went looking for a new article topic today and ended up rereading all five of these blocks back to back, because I wanted to check something: does this pattern actually hold everywhere, or does it just feel like it does?
What the pattern looks like when it's followed
server.py's list_repos had a bug where a negative limit fed straight into Python's slice semantics instead of getting rejected — limit=-1 returned every repo but the last one, not an empty list. The fix was a max(0, min(limit, 100)) clamp. Here's the part that matters: the case that proved the bug also became the regression test.
_orig_gh = _gh






