How to find which branches are not covered by tests?

I measure code coverage with a small Python application.

Although line coverage is 100%, branch coverage is not. The problem is that coverageit will not give me any indication regarding the location of branches that are not covered.

coverage run
    --branch
    --omit=/usr/lib/python3/dist-packages/*,tests/*
    -m unittest discover

returns:

Ran 33 tests in 0.079s

OK
Name              Stmts   Miss Branch BrMiss  Cover   Missing
-------------------------------------------------------------
app/__init__          1      0      0      0   100%   
app/file_finder      93      0     40      0   100%   
app/zipper           66      0     46      7    94%   
-------------------------------------------------------------
TOTAL               160      0     86      7    97%   

I would expect the column to Missingcontain rows corresponding to the seven missing branches, but there is nothing there.

How do I find them?

+4
source share
2 answers

-mwill only include “full” misses, not branch misses. You can use the command

coverage html

HTML-, , . . HTML-, .

+5

, , cover.py 4.0 .

+4

All Articles