if you run doctest on this functionyou will get failure report such as this*********************************************************************file "half py"line in _main_ half failed examplehalf( expected got *********************************************************************to fix thisyou either need to make the documentation exactly match the output or need to pick better example in the documentation because using doctest is almost trivialthere is almost no excuse for not using it with your own programs howeverkeep in mind that doctest is not module you would typically use for exhaustive program testing doing so tends to result in excessively long and complicated documentation strings--which defeats the point of producing useful documentation ( user will probably be annoyed if he asks for help and the documentation lists examples covering all sorts of tricky corner casesfor this kind of testingyou want to use the unittest module lastthe doctest module has large number of configuration options that concerns various aspects of how testing is performed and how results are reported because these options are not required for the most common use of the modulethey are not covered here consult unit testing and the unittest module for more exhaustive program testinguse the unittest module with unit testinga developer writes collection of isolated test cases for each element that makes up program (for exampleindividual functionsmethodsclassesand modulesthese tests are then run to verify correct behavior of the basic building blocks that make up larger programs as programs grow in sizeunit tests for various components can be combined to create large testing frameworks and testing tools this can greatly simplify the task of verifying correct behavior as well as isolating and fixing problems when they do occur use of this module can be illustrated by the code listing in the previous sectionsplitter py def split(linetypes=nonedelimiter=none)"""splits line of text and optionally performs type conversion ""fields line split(delimiterif typesfields ty(valfor ty,val in zip(types,fieldsreturn fields lib fl ff