Chapter 15Testing and Debugging
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 that 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 will 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? In this chapter, you’ll also learn how to find and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access