From 8e7c285c23e686b23b298014fa8fa80a2ef09df6 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 30 Jan 2021 21:52:15 +0200 Subject: [PATCH 1/3] Fix SetupState breakage with upcoming pytest 6.3 pytest 6.3 makes some changes to the SetupState class, adjust to that. --- CHANGES.rst | 4 ++++ pytest_rerunfailures.py | 22 ++++++++++++++-------- tox.ini | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f1771ab..d517ccb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,6 +18,9 @@ Features - Add support for Python 3.9. (Thanks to `@digitronik`_ for the PR) +- Add support for pytest 6.3. + (Thanks to `@bluetech`_ for the PR) + Other changes +++++++++++++ @@ -26,6 +29,7 @@ Other changes .. _@BeyondEvil: https://github.com/BeyondEvil .. _@digitronik: https://github.com/digitronik +.. _@bluetech: https://github.com/bluetech 9.1.1 (2020-09-29) ------------------ diff --git a/pytest_rerunfailures.py b/pytest_rerunfailures.py index 908d4b7..6787731 100644 --- a/pytest_rerunfailures.py +++ b/pytest_rerunfailures.py @@ -21,6 +21,10 @@ pytest.__version__ ) >= pkg_resources.parse_version("5.4") +PYTEST_GTE_63 = pkg_resources.parse_version( + pytest.__version__ +) >= pkg_resources.parse_version("6.3.0.dev") + def works_with_current_xdist(): """Returns compatibility with installed pytest-xdist version. @@ -205,15 +209,17 @@ def _remove_cached_results_from_failed_fixtures(item): def _remove_failed_setup_state_from_session(item): """ - Note: remove all _prepare_exc attribute from every col in stack of - _setupstate and cleaning the stack itself + Note: remove all failures from every node in _setupstate stack + and clean the stack itself """ - prepare_exc = "_prepare_exc" - setup_state = getattr(item.session, "_setupstate") - for col in setup_state.stack: - if hasattr(col, prepare_exc): - delattr(col, prepare_exc) - setup_state.stack = list() + setup_state = item.session._setupstate + if PYTEST_GTE_63: + setup_state.stack = {} + else: + for node in setup_state.stack: + if hasattr(node, "_prepare_exc"): + del node._prepare_exc + setup_state.stack = [] def _should_hard_fail_on_error(session_config, report): diff --git a/tox.ini b/tox.ini index 90694b3..c69ccca 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,8 @@ deps = pytest54: pytest==5.4.* pytest60: pytest==6.0.* pytest61: pytest==6.1.* + pytest62: pytest==6.2.* + pytestmaster: git+https://github.com/pytest-dev/pytest.git@master#egg=pytest [testenv:linting] basepython = python3 From e083b0058cf0d65b89b3faee427b3a5def325db3 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 14 Feb 2021 11:03:41 +0200 Subject: [PATCH 2/3] Add CI test against pytest 6.2 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c105e3d..9d29512 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,7 @@ jobs: "5.4.*", "6.0.*", "6.1.*", + "6.2.*", ] steps: - uses: actions/checkout@v2 From 37cff45a8cbed073b75980bab85a36ab0a3e13ae Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 14 Feb 2021 11:02:54 +0200 Subject: [PATCH 3/3] Add CI test against pytest master --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9d29512..5d86b49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,6 +33,7 @@ jobs: "6.0.*", "6.1.*", "6.2.*", + "master", ] steps: - uses: actions/checkout@v2 @@ -59,7 +60,11 @@ jobs: - name: Install dependencies run: | python -m pip install -U pip - python -m pip install pytest==${{ matrix.pytest-version }} + if [[ '${{ matrix.pytest-version }}' == 'master' ]]; then + python -m pip install git+https://github.com/pytest-dev/pytest.git@master#egg=pytest + else + python -m pip install pytest==${{ matrix.pytest-version }} + fi python -m pip install -e . - name: Tests