-
Notifications
You must be signed in to change notification settings - Fork 84
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
Teardown of fixture with scope=class is not called if following test passes only after rerun or fails after rerun #241
Comments
In compatibilities I foud, that "This plugin may not be used with class, module, and package level fixtures"! I am really sad. I tried to modify code of plugin and managed to make it working with class-scoped fixture! My code may be not perfect and after reruns fixture with scope=class may called several times even in class, but in my case it is better than teardown is not called at all! I modified a part of original code in the following way:
|
I can confirm this issue having researched one of the falls in my project. |
When using the only_rerun and rerun_except queries (or both), the plug-in was removing the teardown operations from the call-stack before checking to see if the test should be re-run. This resulted in the stack having all fixture operations removed that did not correspond to a function fixture. This commit adds a private variable to each test item that keeps track of whether a test encountered a terminal error. The plugin now checks if a test has encountered a terminal error before attempting to clear the stack. This commit fixes: - pytest-dev#241 - pytest-dev#234
When using the only_rerun and rerun_except queries (or both), the plug-in was removing the teardown operations from the call-stack before checking to see if the test should be re-run. This resulted in the stack having all fixture operations removed that did not correspond to a function fixture. This commit adds a private variable to each test item that keeps track of whether a test encountered a terminal error. The plugin now checks if a test has encountered a terminal error before attempting to clear the stack. This commit fixes: - pytest-dev#241 - pytest-dev#234
When using the only_rerun and rerun_except queries (or both), the plug-in was removing the teardown operations from the call-stack before checking to see if the test should be re-run. This resulted in the stack having all fixture operations removed that did not correspond to a function fixture. This commit adds a private variable to each test item that keeps track of whether a test encountered a terminal error. The plugin now checks if a test has encountered a terminal error before attempting to clear the stack. This commit fixes: - #241 - #234
@icemac Hello! As I understand the incompatibility "This plugin may not be used with class, module, and package level fixtures" is overcome now. Am I right? |
@ExplorerOL I think this is no longer a problem. |
Good day! I found out a problem, that teardown of fixture with scope=class not called if following test passed only after rerun or fails after rerun. I tend to think that problem is in plugin pytest-rerunfailures. I use python==3.11.0, pytest==7.2.1, pytest-rerunfailures==12.0. It also happens with pytest-rerunfailures==11.1.2. It causes big problems with my testrun.
Sample of code when teardown of fixture is not called when following test passes only after rerun:
Log:
Sample of code when teardown of fixture is not called when following test fails after rerun:
Log:
Sample of code without reruns and normal teardown:
Log without reruns:
Could you help me, is this problem related with this plugin?
The text was updated successfully, but these errors were encountered: