-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix cleanup functions not being invoked on test failures #7151
Fix cleanup functions not being invoked on test failures #7151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its generally a good idea to unify the wrapping
its unfortunate the async cant be integrated easily/sanely
@@ -537,28 +537,24 @@ def f(_): | |||
) | |||
result.stdout.fnmatch_lines( | |||
[ | |||
"test_trial_error.py::TC::test_four SKIPPED", | |||
"test_trial_error.py::TC::test_four FAILED", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverts the test to the state before 04f27d4, which introduced the breaking change about addCleanup not being called properly for failed tests.
a8e13e1
to
a50fe4a
Compare
20ac646
to
e244e32
Compare
|
||
# let the unittest framework handle async functions | ||
if is_async_function(self.obj): | ||
self._testcase(self) | ||
else: | ||
setattr(self._testcase, self._testcase._testMethodName, wrapped_testMethod) | ||
# when --pdb is given, we want to postpone calling tearDown() otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please review this bit @RonnyPfannschmidt? I noticed this was needed after one of the tests failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm actually YOLO on that one, my insight to the implementation of unittest is limited
|
||
# let the unittest framework handle async functions | ||
if is_async_function(self.obj): | ||
self._testcase(self) | ||
else: | ||
setattr(self._testcase, self._testcase._testMethodName, wrapped_testMethod) | ||
# when --pdb is given, we want to postpone calling tearDown() otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm actually YOLO on that one, my insight to the implementation of unittest is limited
Also delay calling tearDown() when --pdb is given, so users still have access to the instance variables (which are usually cleaned up during tearDown()) when debugging. Fix pytest-dev#6947
This reverts the test to the state before 04f27d4, which introduced the breaking change about addCleanup not being called properly for failed tests.
e244e32
to
82f584b
Compare
Thanks @RonnyPfannschmidt! |
Fix #6947