This library provides a way to check examples in your code and documentation by parsing them from their source and evaluating the parsed examples as part of your normal test run. Integration is provided for the main Python test runners.
The documentation is the best place to start.