Do not report abstract methods as missing coverage
See original GitHub issueSummary
This feature requests especially concerns the term-missing
report.
By their nature, methods decorated with abc.abstractmethod
cannot be called directly.
In the example below, pytest-cov
would consider pass
to be an uncovered statement.
@abc.abstractmethod
def some_abstract_method():
pass
In this situation, it’s impossible to reach 100% coverage.
I acknowledge that it’s possible to use the raise NotImplementedError
approach instead of @abc.abstractmethod
.
However, I personally prefer to make use of abstract methods.
I would therefore greatly appreciate a feature that allows pytest-cov
to omit abstract methods.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:22
- Comments:7 (1 by maintainers)
Top Results From Across the Web
python - Excluding abstractproperties from coverage reports
on my project, it complains that the property def line is untested. It can't actually be tested (AFAIK) as instantiation of the abstract...
Read more >JaCoCo - FAQ
Why are abstract methods not shown in coverage reports? Abstract methods do not contain code, therefore code coverage cannot be evaluated. Indeed code...
Read more >Writing the title and abstract for a research paper - NCBI - NIH
The “abstract” needs to be simple, specific, clear, unbiased, honest, concise, precise, stand-alone, complete, scholarly, (preferably) structured, and should ...
Read more >Instructions for Authors | JAMA Dermatology
Case reports are not included in this section; see Observation. 1200 words; 15 references; ≤3 tables and/or figures; Structured abstract; Key Points ...
Read more >Configuration reference — Coverage.py 6.4.4 documentation
Coverage.py options can be specified in a configuration file. ... Don't complain about abstract methods, they aren't run: @(abc\.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For future readers, I’ve just realised this can easily by done by adding
pass
toexclude_lines
in.coveragerc
(described here and here):Another approach, which I now prefer, is to remove the
pass
altogether. It’s not required if the method has a doc string.Future readers may prefer to simply document their abstract methods rather than leaving them empty. So this can be changed:
To this:
Some may prefer to leave
pass
showing red in the coverage report as a gentle reminder to document.