You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally reported byDavid MacIver (Bitbucket: david_maciver_, GitHub: Unknown)
It seems that code which incorrectly has things before the encoding comment confuses coverage.
Reproduction:
conventions.py:
from __future__ importdivision, print_function, absolute_import# coding=utf-8classUniqueIdentifier(object):
def__init__(self):
passnot_set=UniqueIdentifier()
test_conventions.py:
import conventions
Then running the following:
python -m coverage run test_conventions.py && coverage report --show-missing
Causes coverage to report that the file conventions.py has not got 100% coverage (it does), but also gives nonsensical line numbers:
Name Stmts Miss Cover Missing
---------------------------------------------------
conventions.py 5 3 40% 4, 7-10
test_conventions.py 1 0 100%
---------------------------------------------------
TOTAL 6 3 50%
Line 4 is the encoding comment, and lines 7-10 correspond to the class body.
I have tested this on Python 3.4.3 running coverage 4.0.2. I noticed this when my CI started breaking (I erroneously had some code like this due to a confused formatter) on a coverage upgrade, so I think it's probably introduced in a recent version.
Originally reported by David MacIver (Bitbucket: david_maciver_, GitHub: Unknown)
It seems that code which incorrectly has things before the encoding comment confuses coverage.
Reproduction:
conventions.py:
test_conventions.py:
Then running the following:
Causes coverage to report that the file conventions.py has not got 100% coverage (it does), but also gives nonsensical line numbers:
Line 4 is the encoding comment, and lines 7-10 correspond to the class body.
I have tested this on Python 3.4.3 running coverage 4.0.2. I noticed this when my CI started breaking (I erroneously had some code like this due to a confused formatter) on a coverage upgrade, so I think it's probably introduced in a recent version.
The text was updated successfully, but these errors were encountered: