-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Incorrect coverage report with cover-branches under python 2.7 #502
Comments
Hmm, odd. Thanks for the report. BTW, if you change "while True:" to "while x:", it correctly shows 0%, so there's something going on with the constant-branch detection. |
When I make it a function like this:
I get 40% as the coverage number. |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) The while True is statically marked as covered because it only has one branch (the loop will never end). When computing statistics, it is excluded from the list of missing arcs regardless of the fact that the code leading to this arc was run or not. The problem does not exist in python3 because coverage.py find while True using AST instead of regexps on the sources and avoid creating arcs that cannot be reached.
|
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) For the record https://bitbucket.org/ned/coveragepy/pull-requests/103/also-use-ast-for-while-constants-in-python/diff should fix the issue for python 2.7+ |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) For the record an alternate fix was proposed earlier this year |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) For the record the updated pull request is at https://bitbucket.org/ned/coveragepy/pull-requests/117/also-use-ast-for-while-constants-in-python/diff |
also use AST for while constants in python-2.7 #502 The node.id is set to False, True or None is python-2.7: there is no close #502 → <<cset d9cc167007ef (bb)>> |
Fixed in the commits culminating in deaddb34f45e (bb) |
This fix was released as part of Coverage.py 4.3. |
Originally reported by Artem Dayneko (Bitbucket: jamert, GitHub: jamert)
coverage report
shows non-zero coverage on completely untested files (tested under 2.7.11 and 3.5.1 on Mac OS X El Capitan - only Python 2 is affected)Minimal example of code you can see in repository:
https://bitbucket.org/jamert/coverage-branch-report-issue
As preview: code like this
while completely untested, shows non-zero coverage with the following configuration:
(I would expect zero percent coverage on it).
Steps for reproducing:
Under 3.5.1 is shows different numbers:
The text was updated successfully, but these errors were encountered: