Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: How do I exclude docstrings in code coverage reporting?

I'm trying to figure out how to edit the .coveragerc file so that docstrings aren't included in the percentage of code coverage. This is what I've tried:

[report]
exclude_lines =
    """

and I've also tried

[report]
exclude_lines =
    \"\"\"

but I still get shown near 100% code coverage for a script that is mainly made of docstrings.

like image 503
Eddy Avatar asked Feb 17 '26 18:02

Eddy


1 Answers

Ah nevermind, my mistake, it turns out that they are already ignored. It's just that I was using the Pycharm editor, which highlights these docstring lines in green but they do not actually contribute to the percentage of code coverage

like image 190
Eddy Avatar answered Feb 20 '26 07:02

Eddy