Lesson 36. Testing and debugging your programs
After reading lesson 36, you’ll be able to
- Use the unittest library
- Write tests for your program
- Efficiently debug your programs
It’s unlikely that you’ll write a perfect program on the first try. Often you’ll write code, test it with a few inputs, make changes to it, and test it again, repeating this process until your program runs as expected.
Think about your experience in programming so far. When you write a program and it doesn’t work, what kinds of things do you do to fix it?
Answer:
Look at the error message, if any, and see whether there are clues like line numbers that can direct me toward the issue. Put print statements at certain locations. Try a different input. ...
Get Get Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.