How do I test a Python program or component?
Python comes with two testing frameworks.
The doctest module finds examples in the docstrings for a module and runs them, comparing the output with the expected output given in the docstring. You can use this for more extensive testing either by writing separate test programs, and using doctest to verify that the test programs behave properly, or by putting the tests in separate text files.
The unittest module is more traditional testing framework modelled on Java and Smalltalk testing frameworks.