Incorrect coverage report with cover-branches under python 2.7 · Issue #502 · nedbat/coveragepy (original) (raw)
Originally reported by Artem Dayneko (Bitbucket: jamert, GitHub: jamert)
coverage report
shows non-zero coverage on completely untested files (tested under 2.7.11 and 3.5.1 on Mac OS X El Capitan - only Python 2 is affected)
Minimal example of code you can see in repository:
https://bitbucket.org/jamert/coverage-branch-report-issue
As preview: code like this
#!python
class Klass(object):
def method(self):
while True:
return 1
while completely untested, shows non-zero coverage with the following configuration:
#!bash
$ cat .coveragerc
[run]
source = src
branch = True
(I would expect zero percent coverage on it).
Steps for reproducing:
#!bash
$ coverage run src/tested.py # empty file
$ coverage report
Name Stmts Miss Branch BrPart Cover
-------------------------------------------------
src/code.py 4 4 2 0 33%
src/tested.py 0 0 0 0 100%
-------------------------------------------------
TOTAL 4 4 2 0 33%
Under 3.5.1 is shows different numbers:
#!bash
$ coverage report
Name Stmts Miss Branch BrPart Cover
-------------------------------------------------
src/code.py 4 4 0 0 0%
src/tested.py 0 0 0 0 100%
-------------------------------------------------
TOTAL 4 4 0 0 0%