Code from the Python Testing Cookbook