Types of errors and how to read a traceback
All programmers make mistakes, every day. The difference between a beginner and a professional is that the professional knows how…
Learn to find and prevent errors the way professionals do. In this lesson you will learn how to read a traceback, how to debug with traces, logging and breakpoint(), how to check your code with assert, how to write tests with unittest and how to design good test cases, including boundary values.
All programmers make mistakes, every day. The difference between a beginner and a professional is that the professional knows how…
Debugging is finding and fixing the cause of an error. It does not consist of trying things at random: it is a method.
The best way to find logic errors is to test the code with cases whose result you already know . The simplest tool in Python is…
With assert and a table of cases you can already test your code. But when a project grows, it is worth using a test framework …
Writing tests is easy. Writing good tests, the ones that really find errors, requires thinking about which cases to choose.
Create a Python program that extracts the important information from a traceback , the message that Python shows when an…
Create a Python program that uses traces ( print messages) to follow the value of the variables step by step, the simplest…
Create a Python program that tests a function with a list of cases using assert .
Create a Python program that runs a test table : a list of inputs with the expected result of each one.
This function has a hidden bug . Create a program that finds it by comparing its result with the correct one in several cases.
Create a Python program that defines a test with unittest , runs it from the program itself and counts the failures.
Create a Python program that uses the logging module to record messages with different levels and show only the important ones.
Create a Python program with a function that checks its preconditions with assert and an error message.
Create a Python program with a function whose most important test cases are at the boundaries of each interval: just before…