February 2022
Intermediate to advanced
274 pages
6h 28m
English
In the HTML reports generated in the previous section, notice the inclusion of a column that indicates “0 excluded.” This refers to a feature of coverage that allows us to exclude some lines from being tested. In Cards, we aren’t excluding anything. But it’s not unusual to exclude some code from being part of the coverage calculation.
As an example, a module that can be either imported or run directly might include a block like this:
| | if __name__ == '__main__': |
| | main() |
This command tells Python to run main() if we call the module directly, like python some_module.py, but not to run the code if the module is imported.
These types of blocks are frequently excluded from testing with a simple pragma statement: ...
Read now
Unlock full access