doctest and unittest
The one of the important aspects of software development is testing of the software. The testing is done to check whether the developed software works in all desired situations properly. unittest is preparation of test conditions before the development of code for each and every functions we are intending to do. In case of doctest test conditions are embedded along with the docstring of each methods.
In doctest testing along with the docstring ,test condition and the corresponding result are given. This provide the users to look into the working of the section with an example. We can make the test running by calling a method testmod() which is present in the module doctest.
If the code written by us is correct it will return the result as ok, otherwise returns failiure.
unittest allow to maintain the test module in a new file and can run it any time we need to test explicitly.The test conditions in unittest are actually made before the coding of the original code. It is the first step of coding. It makes the problem very clear thus making us to work for that specific goal. It will control us from deviating from the goal.
On calling the unittest.main(), the main() method of unittest is invoked. This will make the test running and the output formating is done. If a failure occur number of failed test and trackback to the most recent call is shown.
The problem with unittest is the module will only test the method which starts the name ‘test’.