-
-
Notifications
You must be signed in to change notification settings - Fork 448
Closed
Labels
annotatebugSomething isn't workingSomething isn't workingwontfixThis will not be worked onThis will not be worked on
Description
Originally reported by Anonymous
coverage annotate
considers lines after if False
to be covered:
% python -m coverage run t.py && python -m coverage annotate t.py && python -m coverage report -m && cat t.py,cover
1
Name Stmts Miss Cover Missing
-------------------------------------
t.py 1 0 100%
> if False:
> print('never')
> print(1)
I know that if False
is a special case (optimization), but AnnotateReporter.annotate_file
should handle it properly.
analysis.statements
is [3]
in this case, that's why the covered
logic kicks in later only.
Since covered
gets not updated for the if False
, it will be considered to be uncovered in the following case, because the previous line sets covered=False
:
1
Name Stmts Miss Cover Missing
-------------------------------------
t.py 4 1 75% 3
> a = 0
> if a:
! print(0)
! if False:
! print('never')
> print(1)
Metadata
Metadata
Assignees
Labels
annotatebugSomething isn't workingSomething isn't workingwontfixThis will not be worked onThis will not be worked on