Hacker News new | ask | show | jobs
by flakes 394 days ago
Really loving those markdown style tests. I think it's a really fantastic idea that allows the tests to easily act as documentation too.

Can you explain how you came up with this solution? Rust docs code-examples inspired?

4 comments

That concept has been formalized as part of the Python standard library.

https://docs.python.org/3/library/doctest.html

Ah very nice! Did not realize this was a part of the standard library!
Here is the first announce of doctest I can find (1999) I think it's Python 1.5 time.

https://groups.google.com/g/comp.lang.python/c/DfzH5Nrt05E/m...

I use this in my books to show the output but also to "test" that the code found in my books actually works.
I love doctest as it works so well with a REPL but unfortunately it hasn't really gained traction anywhere I've seen.