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

Number of statement detection wrong if no newline at end of file #293

Closed
nedbat opened this issue Mar 18, 2014 · 1 comment
Closed

Number of statement detection wrong if no newline at end of file #293

nedbat opened this issue Mar 18, 2014 · 1 comment
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Mar 18, 2014

Originally reported by Marc Schlaich (Bitbucket: schlamar, GitHub: schlamar)


Coverage does not detect number of statements correctly in a multi line statement if it is not followed by a newline until Python 3.3. It works in Python 3.4.

#!text

$ cat cov_error.py
import subprocess
import sys

out, err = subprocess.Popen(
    [sys.executable, '-c', 'pass'],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE).communicate()
$ py -2.7 -m coverage run cov_error.py && py -2.7 -m coverage report
Name        Stmts   Miss  Cover
-------------------------------
cov_error       6      0   100%

$ echo "" >> cov_error.py
$ py -2.7 -m coverage run cov_error.py && py -2.7 -m coverage report
Name        Stmts   Miss  Cover
-------------------------------
cov_error       3      0   100%

$ # revert new line in editor
$ py -3.3 -m coverage run cov_error.py && py -3.3 -m coverage report
Name        Stmts   Miss  Cover
-------------------------------
cov_error       6      0   100%

$ py -3.4 -m coverage run cov_error.py && py -3.4 -m coverage report
Name        Stmts   Miss  Cover
-------------------------------
cov_error       3      0   100%



@nedbat
Copy link
Owner Author

nedbat commented Nov 29, 2014

Fixed in 1d6d567403cf (bb)

@nedbat nedbat closed this as completed Nov 29, 2014
@nedbat nedbat added major bug Something isn't working labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant