branch coverage: "if" before "if False" marked as partial wrongly

Issue #598 duplicate
Daniel Hahler created an issue

The following code is considered to be 100% covered, which might be related to (i.e. line 6 should be marked as missed, but is not due to optimization?!):

for a in [True, False]:
    if a:

    if False:

However, when using branch = True, line 2 gets marked as "partial" in the html report, although line 5 should be marked as such instead.

Name         Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------       4      0      4      1    88%   2->5

Python 3.6.2 4.4.1

Comments (4)

  1. Ned Batchelder repo owner

    This is a duplicate of #198, in that the peephole optimizer has removed logical code paths from execution. Coverage cannot recreate the original paths.

  2. Log in to comment