-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Context managers confuse branch coverage #146
Comments
Another report of this from lvh:
|
Issue #248 was marked as a duplicate of this issue. |
Original comment by stefano_palazzo (Bitbucket: stefano_palazzo, GitHub: Unknown) Here's an example that probably describes the same issue:
With "print(f)" claiming to have an untaken branch to "except FileNotFoundError:". |
Original comment by Anthony Sottile (Bitbucket: asottile, GitHub: asottile) Interestingly the following example seems to only plague 2.6 (not 2.7, 3.3, 3.4, pypy from my testing) from __future__ import print_function
from __future__ import unicode_literals
import contextlib
@contextlib.contextmanager
def noop():
yield
def test_foo():
with noop():
with noop():
print('1')
print('2') |
Issue #319 was marked as a duplicate of this issue. |
Issue #362 was marked as a duplicate of this issue. |
Original comment by Jessamyn Smith (Bitbucket: jessamynsmith, GitHub: jessamynsmith) As Ned just taught me, if this is plaguing you, you can add the following to the erroneously not-covered line: pragma: no branch |
Original comment by Buck Evan (Bitbucket: bukzor, GitHub: bukzor) @asottile I've just run into this issue on python 2.7.6.
|
Original comment by Dan Jones (Bitbucket: dannosaur, GitHub: dannosaur) Ran into this as well on Python 2.7.10 (coverage 3.7.1);
"print x" has a missed branch to "except Exception:". |
This will be fixed when the ast-branch is merged. |
Issue #384 was marked as a duplicate of this issue. |
This is fixed in 44719bd (bb), which will be 4.1 |
Issue #470 was marked as a duplicate of this issue. |
Issue #473 was marked as a duplicate of this issue. |
In this code:
Line 9 claims to have an untaken branch to line 11.
The text was updated successfully, but these errors were encountered: