Skip to content

Fix SetupState breakage with upcoming pytest 6.3 #151

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

Merged
merged 3 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
"5.4.*",
"6.0.*",
"6.1.*",
"6.2.*",
"master",
]
steps:
- uses: actions/checkout@v2
Expand All @@ -58,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
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
+++++++++++++

Expand All @@ -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)
------------------
Expand Down
22 changes: 14 additions & 8 deletions pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like testing against master.
This change should also be applied to .github/workflows/test.yml so CI runs them, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added. Using master might of course cause breakage from the pytest side, but hopefully not.


[testenv:linting]
basepython = python3
Expand Down