Some code is hard to test because it depends on something that you do not control: a web service, the clock, a database, a random number. A mock is a stand-in object that you control, which gives the answers that you choose and records how it was used. This lesson shows mocks and patching, then two more tools, doctest, which checks the examples in your documentation, and coverage, which shows what your tests did not reach, and ends with the habits that make a test suite worth keeping.
More lessons in Complete Python Programming