Search code examples
pytestcoverage.py

pytest coverage for class methods


I have a class with many methods that I regularly test with a command

python3 -m pytest --doctest-modules --cov=yarsync --cov-report term-missing yarsync tests

Unfortunately, it outputs missing lines for the whole class (module), like

yarsync/yarsync.py     1031    259    75%   60, 69-70, 77, 160-167, ...

Is it possible to split output based on class methods? I tried annotate, but that seems redundant (and already discouraged by developers).


Solution

  • Coverage.py doesn't divide its reports into methods. You can use the line numbers to find the problem areas in your code. coverage html provides a highlighted HTML report.