Closed ExplorerOL closed 4 months ago
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:
if item in item.session._setupstate.stack:
if PYTEST_GTE_63:
# original code
# for key in list(item.session._setupstate.stack.keys()):
# if key != item:
# del item.session._setupstate.stack[key]
# my code
keys_to_delete = list(item.session._setupstate.stack)[:-2]
for key in keys_to_delete:
if key != item:
del item.session._setupstate.stack[key]
else:
for node in list(item.session._setupstate.stack):
if node != item:
item.session._setupstate.stack.remove(node)
I can confirm this issue having researched one of the falls in my project.
@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?