{"slug": "doctest", "name": "doctest", "category": "dev-libs", "category_name": "Libraries and frameworks", "description": "", "recommenders": 3, "commenters": 3, "warners": 0, "score": 2.73, "rising": 0.35, "first": "2026-03-20", "latest": "2026-10-16", "why": "it is often a quick and easy way to document and test your code/documentation at the same time.", "why_is_quote": true, "has_verdict": false, "sentiment": {"recommend": 3, "neutral": 0, "compare": 0, "warn": 0}, "spark": [0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1], "listed": true, "loved": [], "caveat": "", "short_quote": "it is often a quick and easy way to document and test your code/documentation at the same time.", "kind": "", "icon": true, "domain": "python.org", "github_repo": null, "official_url": "https://docs.python.org/3/library/doctest.html", "pricing": "", "aliases": ["doctest"], "verdict": null, "praise": [{"label": "", "summary": "", "quotes": [{"id": 801987488, "item_id": 50124218, "url": "https://news.ycombinator.com/item?id=50124218", "by": "necovek", "date": "2026-10-16", "stance": "recommend", "quote": "I generally liked Python doctests: runnable documentation.", "excerpt": "I generally liked Python doctests: runnable documentation. It is really an amazing concept, only a step removed from literate programming IMO. Two problems with it were that 1. often setup boilerplate overshadowed the actual essence of the documentation and 2. people abused them for e2e testing making for unreasonable reading (and slow testsuite runs).", "context": "", "use_case": "runnable documentation", "switched_from": "", "story": "Ask HN: Why do developers hate Confluence?"}, {"id": 761047776, "item_id": 47565486, "url": "https://news.ycombinator.com/item?id=47565486", "by": "wiseowise", "date": "2026-03-29", "stance": "recommend", "quote": "Seems pretty related to me.", "excerpt": "> Having a CI job that identifies places where the docs have drifted from the implementation seems pretty valuable. https://docs.python.org/3/library/doctest.html > To check that a module\u2019s docstrings are up-to-date by verifying that all interactive examples still work as documented. To perform regression testing by verifying that interactive examples from a test file or a test object work as expected. To write tutor", "context": "", "use_case": "", "switched_from": "", "story": "Lat.md: Agent Lattice: a knowledge graph for your codebase, written in Markdown"}, {"id": 761019456, "item_id": 47563716, "url": "https://news.ycombinator.com/item?id=47563716", "by": "wiseowise", "date": "2026-03-29", "stance": "recommend", "quote": "Python community figured this out in 2005", "excerpt": "Python community figured this out in 2005: https://docs.python.org/3/library/doctest.html", "context": "", "use_case": "", "switched_from": "", "story": "Lat.md: Agent Lattice: a knowledge graph for your codebase, written in Markdown"}, {"id": 759249312, "item_id": 47453082, "url": "https://news.ycombinator.com/item?id=47453082", "by": "dec0dedab0de", "date": "2026-03-20", "stance": "recommend", "quote": "it is often a quick and easy way to document and test your code/documentation at the same time.", "excerpt": "interesting that they don\u2019t mention doctest which has been a python built-in for quite a while. It allows you to write simple unit tests directly in your doc strings, by essentially copying the repl output so it doubles as an example. combined with something like sphinx that is almost exactly what you\u2019re looking for. doctest kind of sucks for anything where you need to set up state, but if you\u2019re writing functional c", "context": "", "use_case": "", "switched_from": "", "story": "Be intentional about how AI changes your codebase"}]}], "caveats": [], "who": [], "tags": [], "use_cases": ["runnable documentation"], "compared": [], "makers": [], "threads": [{"url": "https://news.ycombinator.com/item?id=47561496", "title": "Lat.md: Agent Lattice: a knowledge graph for your codebase, written in Markdown", "mentions": 2}, {"url": "https://news.ycombinator.com/item?id=50123542", "title": "Ask HN: Why do developers hate Confluence?", "mentions": 1}, {"url": "https://news.ycombinator.com/item?id=47446373", "title": "Be intentional about how AI changes your codebase", "mentions": 1}], "sentiment_by_month": {"2025-11": {}, "2025-12": {}, "2026-01": {}, "2026-02": {}, "2026-03": {"recommend": 2}, "2026-04": {}, "2026-05": {}, "2026-06": {}, "2026-07": {}, "2026-08": {}, "2026-09": {}, "2026-10": {"recommend": 1}}, "quotes": [{"id": 801987488, "item_id": 50124218, "url": "https://news.ycombinator.com/item?id=50124218", "by": "necovek", "date": "2026-10-16", "stance": "recommend", "quote": "I generally liked Python doctests: runnable documentation.", "excerpt": "I generally liked Python doctests: runnable documentation. It is really an amazing concept, only a step removed from literate programming IMO. Two problems with it were that 1. often setup boilerplate overshadowed the actual essence of the documentation and 2. people abused them for e2e testing making for unreasonable reading (and slow testsuite runs).", "context": "", "use_case": "runnable documentation", "switched_from": "", "story": "Ask HN: Why do developers hate Confluence?"}, {"id": 761047776, "item_id": 47565486, "url": "https://news.ycombinator.com/item?id=47565486", "by": "wiseowise", "date": "2026-03-29", "stance": "recommend", "quote": "Seems pretty related to me.", "excerpt": "> Having a CI job that identifies places where the docs have drifted from the implementation seems pretty valuable. https://docs.python.org/3/library/doctest.html > To check that a module\u2019s docstrings are up-to-date by verifying that all interactive examples still work as documented. To perform regression testing by verifying that interactive examples from a test file or a test object work as expected. To write tutor", "context": "", "use_case": "", "switched_from": "", "story": "Lat.md: Agent Lattice: a knowledge graph for your codebase, written in Markdown"}, {"id": 761019456, "item_id": 47563716, "url": "https://news.ycombinator.com/item?id=47563716", "by": "wiseowise", "date": "2026-03-29", "stance": "recommend", "quote": "Python community figured this out in 2005", "excerpt": "Python community figured this out in 2005: https://docs.python.org/3/library/doctest.html", "context": "", "use_case": "", "switched_from": "", "story": "Lat.md: Agent Lattice: a knowledge graph for your codebase, written in Markdown"}, {"id": 759249312, "item_id": 47453082, "url": "https://news.ycombinator.com/item?id=47453082", "by": "dec0dedab0de", "date": "2026-03-20", "stance": "recommend", "quote": "it is often a quick and easy way to document and test your code/documentation at the same time.", "excerpt": "interesting that they don\u2019t mention doctest which has been a python built-in for quite a while. It allows you to write simple unit tests directly in your doc strings, by essentially copying the repl output so it doubles as an example. combined with something like sphinx that is almost exactly what you\u2019re looking for. doctest kind of sucks for anything where you need to set up state, but if you\u2019re writing functional c", "context": "", "use_case": "", "switched_from": "", "story": "Be intentional about how AI changes your codebase"}]}