-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
When assertions fail inside a test, contextmanagers don't work #3365
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
Labels
type: question
general question, might be closed after 2 weeks of inactivity
Comments
For the code block after from contextlib import contextmanager
@contextmanager
def hello():
print("this runs")
try:
yield
finally:
print("this doesn't run")
def test_hello():
with hello():
assert 1 == 0 This is how |
closing as this one is entirely about core python behaviour |
schopin-pro
added a commit
to schopin-pro/apport
that referenced
this issue
Jul 21, 2023
Our context manager improperly failed to deal with exceptions thrown in the block under context, resulting in the test process never being killed. See pytest-dev/pytest#3365
bdrung
pushed a commit
to canonical/apport
that referenced
this issue
Jul 21, 2023
Our context manager improperly failed to deal with exceptions thrown in the block under context, resulting in the test process never being killed. See pytest-dev/pytest#3365
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description of the bug
When assertions fail inside a test, context managers don't work.
Test code
Running the above code with pytest -s yields
pip list
of the virtual environmentpytest and operating system versions
pytest=3.5.0, python=3.6, OS=ArchLinux
The text was updated successfully, but these errors were encountered: