Like program source code,
doctest tests are written in plain text. The
doctest module extracts the tests and ignores the rest of the text, which means that the tests can be embedded in human-readable explanations or discussions. This is the feature that makes
doctest suitable for uses such as program specifications.
We are going to create a simple
doctest file, to show the fundamentals of using the tool. Perform the following steps:
This is a simple doctest that checks some of Python's arithmetic operations. >>> 2 + 2 4 >>> 3 * 3 10
doctest. At the command prompt, ...