Describe the bug
I used coverage.py 4.5.1 and 4.5.3 packaged in coverage-4.5win.exe (e.g. coverage-4.5.3.win-amd64-py3.7.exe) on 32bit and 64bit versions of Python 2.7/3.4/3.6/3.7. The bug is related to (if I remember right) all versions of coverage.py which leads in misaligned coverage lines in the generated coverage report. The coverage itself seems to be correct.
The superfluous backslash after „# 4 numbers“ is the reason for the problem. This backslash leads to the misaligned coverage lines as you can see at the enclosed coverage report (coverageBad/index.html). Original line 5 in the generated report („print( "Message 2" )“) becomes line 6 and is not covered which is obviously wrong.
If you remove the backslash (myExampleGood.py), the generated coverage report will be correct as you can see at the enclosed coverage report (coverageGood/index.html).
How can we reproduce the problem? Please be specific.
What version of Python are you running?
Any. 2.7/3.4/3.6/3.7 (32 and 64Bit versions)
What versions of what packages do you have installed? The output of pip freeze is very helpful.
coverage.py 4.5.1, 4.5.3
What code are you running? Give us a specific commit of a specific repo that we can check out.
print( "Message 1" )
array = [ 1,2,3,4, # 4 numbers
5,6,7 ] # 3 numbers
print( "Message 2" )
See examples in the enclosed zip archive.
What commands did you run?
C:\Tools\Python\2.7.9_64Bit\Scripts\coverage.exe run -a --rcfile=c:\bugReportCoverage.py\coverage.coverage.rc myExampleBad.py
C:\Tools\Python\2.7.9_64Bit\Scripts\coverage.exe html --rcfile=c:\bugReportCoverage.py\coverage.coverage.rc
Each coverage line should be marked as covered.
Superfluous backslash should be ignored.
No new line should be added.
This seems to be only a problem while generating a report. The coverage itself seems to be detected correctly.