code from "Testing Python" book