Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misaligned lines in coverage reports using coverage #822

Closed
Eagleeis opened this issue Jul 11, 2019 · 3 comments
Closed

Misaligned lines in coverage reports using coverage #822

Eagleeis opened this issue Jul 11, 2019 · 3 comments
Labels
bug

Comments

@Eagleeis
Copy link

@Eagleeis Eagleeis commented Jul 11, 2019

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).

To Reproduce
How can we reproduce the problem? Please be specific.

  1. What version of Python are you running?
    Any. 2.7/3.4/3.6/3.7 (32 and 64Bit versions)

  2. 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

  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.

  4. What commands did you run?
    cd c:\bugReportCoverage.py
    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

Expected behavior
Each coverage line should be marked as covered.
Superfluous backslash should be ignored.
No new line should be added.

Additional context
This seems to be only a problem while generating a report. The coverage itself seems to be detected correctly.

myExample.zip

@Eagleeis Eagleeis added the bug label Jul 11, 2019
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat nedbat commented Aug 6, 2019

Thanks for the reproducible report. I don't have a fix yet, it's not as simple as I had hoped.

nedbat added a commit that referenced this issue Aug 11, 2019
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat nedbat commented Aug 11, 2019

Fixed in commit 1a27df4

@nedbat nedbat closed this Aug 11, 2019
@nedbat

This comment has been minimized.

Copy link
Owner

@nedbat nedbat commented Sep 21, 2019

This is in 5.0a7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.