June 2017
Beginner to intermediate
274 pages
6h 49m
English
Including examples of use in our docstrings is common, but if we're not careful, those examples can get left behind when the code changes, and the wrong documentation is worse than no documentation. Fortunately, we have a tool that can check whether the documentation agrees with the code by running the examples from our documentation and seeing what happens. That tool is called doctest.
To enable doctest to recognize our examples as things it can test, all we have to do is include the Python interactive shell prompt into our example. In the simplest and most common case, that just means putting a >>> symbol in front of each statement, as shown in the following screenshot. For multi-line statements, ...
Read now
Unlock full access