unittest
The unittest module is used to perform unit testing. With unit testing, a developer writes a collection of isolated test cases for each element that makes up a program (for example, individual functions, methods, classes, and modules). These tests are then run to verify correct behavior. As programs grow in size, unit 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 isolating and fixing problems when they do occur. Use of the module is best illustrated by an example. For instance, suppose you had the following Python module:
# module: gcd.py def gcd(x,y): if not (isinstance(x,(int,long)) and isinstance(y,(int,long))): ...
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.