The Algorithms in Python: Testing binary and using doctest
The code includes documentation which is partially free text and partially examples that look as if they were written in the interactive shell of Python with >>> being the prompt. An example call to the function is followed by the expected result.
The result must be once verified manually and then it becomes the expected result. From that point on the developer can verify that the documentation corresponds to the implementation and that changes in the implementation don't break the already established correct results.
Published on 2022-11-13