The Algorithms in Python: Testing binary and using doctest
The Algorithms is a project hosted on GitHub that has the implementation of various interesting algorithms in various programming languages.
In this video we take a look at one of the simple algorithms and how it is being tested.
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