doctest
doctest is a module in the Python programming language that allows developers to test their code by embedding test cases within the documentation. It enables users to write simple tests as part of the docstrings, which can be executed to verify that the code behaves as expected. This approach helps ensure that examples in the documentation remain accurate and functional.
When a doctest is run, it compares the output of the code with the expected results specified in the docstring. If the outputs match, the test passes; if not, an error is reported. This makes it a useful tool for both testing and documentation purposes.