[Python-Dev] We now have C code coverage!

Terry Reedy tjreedy at udel.edu
Thu Jun 28 20:28:13 EDT 2018

On 6/24/2018 5:03 AM, Ammar Askar wrote:
>> Is it possible, given that we are not paying for those reports, to
>> customize the 'exclude_lines' definitions?
> Do you want to exclude python code or C code?

Python code.

> For Python code, coverage.py also has some comments you can
> put down to exclude lines:
> http://coverage.readthedocs.io/en/coverage-4.2/excluding.html

Yes, by default, one can use '# pragma: no cover' and if one uses the 
--branch flag, '# pragma: no branch'.  For more 'advanced exclusion', 
one can use the following, normally in .coveragerc.
exclude_lines = ...
"This is useful if you have often-used constructs to exclude that can be 
matched with a regex. You can exclude them all at once without littering 
your code with exclusion pragmas."

For IDLE's test suite, I use a customized .coveragerc.  I strongly 
prefer to not abandon that and litter the code with # pragmas.

In order to make sense of the coverage report and have it be truthful, 
one needs to know what options are being used.
Is the --branch flag set?
Is .coveragerc or some other configuration file in use?
If so, what is the content?
Do we have any control over the use and content of exclusion settings?

Terry Jan Reedy

More information about the Python-Dev mailing list