Skip to content

Commit 381ada9

Browse files
committed
Fix SetupState breakage with upcoming pytest 6.3
pytest 6.3 makes some changes to the SetupState class, adjust to that.
1 parent 8f15199 commit 381ada9

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

pytest_rerunfailures.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
pytest.__version__
2222
) >= pkg_resources.parse_version("5.4")
2323

24+
PYTEST_GTE_63 = pkg_resources.parse_version(
25+
pytest.__version__
26+
) >= pkg_resources.parse_version("6.3.0.dev")
27+
2428

2529
def works_with_current_xdist():
2630
"""Returns compatibility with installed pytest-xdist version.
@@ -205,15 +209,17 @@ def _remove_cached_results_from_failed_fixtures(item):
205209

206210
def _remove_failed_setup_state_from_session(item):
207211
"""
208-
Note: remove all _prepare_exc attribute from every col in stack of
209-
_setupstate and cleaning the stack itself
212+
Note: remove all failures from every item in _setupstate stack
213+
and clean the stack itself
210214
"""
211-
prepare_exc = "_prepare_exc"
212-
setup_state = getattr(item.session, "_setupstate")
213-
for col in setup_state.stack:
214-
if hasattr(col, prepare_exc):
215-
delattr(col, prepare_exc)
216-
setup_state.stack = list()
215+
setup_state = item.session._setupstate
216+
if PYTEST_GTE_63:
217+
setup_state.stack = {}
218+
else:
219+
for col in setup_state.stack:
220+
if hasattr(col, "_prepare_exc"):
221+
del col._prepare_exc
222+
setup_state.stack = []
217223

218224

219225
def _should_hard_fail_on_error(session_config, report):

tox.ini

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ deps =
2424
pytest54: pytest==5.4.*
2525
pytest60: pytest==6.0.*
2626
pytest61: pytest==6.1.*
27+
pytest62: pytest==6.2.*
28+
pytestmaster: git+https://github.com/pytest-dev/pytest.git@master#egg=pytest
2729

2830
[testenv:linting]
2931
basepython = python3

0 commit comments

Comments
 (0)