How can you tell whether the programs you write work correctly? Following the function design recipe from Designing New Functions: A Recipe, you include an example call or two in the docstring. The last step of the recipe is calling your function to make sure it returns what you expect. But are one or two calls enough? If not, how many do you need? How do you pick the arguments for those function calls? In this chapter, you’ll learn how to choose good test cases and how to test your code using Python’s unittest module.
Finally, what happens if your tests fail, revealing a bug? (See What’s a Bug?.) How can you tell where the problem is in your code? This chapter will also teach you how to find and fix bugs in your programs.