-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
Report ignores decorators when run on Python 3.8 if testing was done on previous Python versions. #941
Comments
Rawhide defaults to Python 3.8 and we get hit by this issue: nedbat/coveragepy#941 Signed-off-by: Aurélien Bompard <[email protected]>
Rawhide defaults to Python 3.8 and we get hit by this issue: nedbat/coveragepy#941 Signed-off-by: Aurélien Bompard <[email protected]>
Rawhide defaults to Python 3.8 and we get hit by this issue: nedbat/coveragepy#941 Signed-off-by: Aurélien Bompard <[email protected]>
I just wanted to second that I am also having this issue with my project (e.g. https://codecov.io/gh/cropsinsilico/yggdrasil/src/1a39f11e62cd6924633c14caa613aae31899f9d1/yggdrasil/drivers/tests/test_CMakeModelDriver.py). |
I'm not sure what to do about this. Different versions of Python trace lines slightly differently. Coverage.py "knows" what lines Python 3.7 will trace, and also what lines 3.8 will trace. When recording execution, coverage.py just records whatever Python reports. During the reporting phase, it takes into account the version of Python to determine what lines could have been traced but were not. So when the measurement is on a different version than the reporting, the "could have" logic is off, and lines get incorrectly marked as missing. (I feel like I wrote this recently on another issue, but I can't find it.) |
Oh, this is a duplicate of #866 |
Describe the bug
If the
coverage run
is done on Python < 3.8 and thecoverage report
is done on Python 3.8, the lines following decorators (the function/method/class definitions) will be ignored and result in lower coverageTo Reproduce
Here's a file to reproduce it:
Here's what I get when I run coverage with different Python versions:
The test run has been done with Python 3.6. Now the report:
Coverage correctly reports 100% coverage if the reporting is done with Python 3.6 (or 3.7 for that matter)
When run with Python 3.8,
coverage report
thinks the method definition was not covered. It would behaved correctly without the decorator.Here are the versions in both cases:
I'm available if you need any more info. My use case might not even be supported, but I thought I'd report it in case it helps explain other issues.
The text was updated successfully, but these errors were encountered: