We have already seen in Chapter 1, Getting Started with Software Testing, how code coverage by tests is a good measure for establishing how confident you can be in your test suite. A test suite that only runs 10% of all our code is probably not going to be very reliable in finding problems, as most of the code will go unchecked. A test suite that instead verifies 100% of our code is certainly going to exercise every single line of code we wrote and so should trigger bugs more easily if there are any.
Obviously, coverage cannot verify code that you never wrote, so it's not going to detect that you have a bug because you forgot to add an if check in your method, but at least it tells you if you forgot to write a test for that method.
Normally, test coverage in Python is done using the coverage module, which can be installed from PyPI, but PyTest has a convenient pytest-cov plugin that is going to do that for us and make our life simpler when...