'pass' causes pragma no cover to be ignored

Issue #576 closed
John Vandenberg
created an issue

If a branch only contains pass it is required to be covered even if the branch is #pragma: no cover.

For example, in the following

foo = True

if foo == True:
    foo = False
else:  # pragma: no cover

if foo == False:
    foo = True
else:  # pragma: no cover

Only the first else requires coverage; using None instead of pass rectifies the problem.

$ coverage report --show-missing
Name               Stmts   Miss Branch BrPart  Cover   Missing
coverage_demo.py       5      0      2      1    86%   3->8

Comments (1)

  1. Log in to comment