coveragepy
coveragepy copied to clipboard
'pass' causes pragma no cover to be ignored
Originally reported by John Vandenberg (Bitbucket: jayvdb, GitHub: jayvdb)
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
pass
if foo == False:
foo = True
else: # pragma: no cover
None
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
- Bitbucket: https://bitbucket.org/ned/coveragepy/issue/576
@nedbat potential issue for sprint?
This feels like something that behaves differently on different versions of Python. We should investigate.