python two of the most notable are nose (code google com/ /python-nose)which aims to be more comprehensive and useful than the standard unittest modulewhile still being compatible with itand py test (codespeak net/py/dist/test/test html)--this takes somewhat different approach to unittestand tries as much as possible to eliminate boilerplate test code both of these third-party tools support test discoveryso there is no need to write an overarching test program--since they will search for tests themselves this makes it easy to test an entire tree of code or just part of the tree ( just those modules that have been worked onfor those serious about testing it is worth investigating both of these third-party modules (and any others that appeal)before deciding which testing tools to use creating doctests is straightforwardwe write the tests in the modulefunctionclassand methodsdocstringsand for moduleswe simply add three lines at the end of the moduleif __name__ ="__main__"import doctest doctest testmod(if we want to use doctests inside programsthat is also possible for examplethe blocks py program whose modules are covered later (in has doctests for its functionsbut it ends with this codeif __name__ ="__main__"main(this simply calls the program' main(functionand does not execute the program' doctests to exercise the program' doctests there are two approaches we can take one is to import the doctest module and then run the program--for exampleat the consolepython - doctest blocks py (on windowsreplacing python with something like :\python \python exeif all the tests run fine there is no outputso we might prefer to execute python - doctest blocks py - insteadsince this will list every doctest that is executedand provide summary of results at the end another way to execute doctests is to create separate test program using the unittest module the unittest module is conceptually modeled on java' junit unit testing library and is used to create test suites that contain test cases the unittest module can create test cases based on doctestswithout having to know anything about what the program or module containsapart from the fact that it has doctests so to make test suite for the blocks py programwe can create the following simple program (which we have called test_blocks py)import doctest import unittest import blocks