Skip to content

Commit

Permalink
Add support for Python 3.12. (#245)
Browse files Browse the repository at this point in the history
* Drop support for pytest < 7.0.
* Drop pytest < 7 code.
  • Loading branch information
icemac authored Nov 22, 2023
1 parent f3ef8b3 commit fa7b4e4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
"3.9",
"3.10",
"3.11",
"3.12",
"pypy-3.9",
]
pytest-version: [
"6.2.*",
"7.0.*",
"7.1.*",
"7.2.*",
Expand All @@ -39,7 +39,7 @@ jobs:
"main",
]
exclude:
# pytest-main opnly supports Python 3.8+
# pytest-main only supports Python 3.8+
- { python-version: "3.7", pytest-version: "main" }
steps:
- uses: actions/checkout@v3
Expand Down
15 changes: 14 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
Changelog
=========

12.1 (unreleased)
13.0 (unreleased)
-----------------

Breaking changes
++++++++++++++++

- Drop support for pytest < 7.0.

Features
++++++++

- Add support for Python 3.12.

Bug fixes
+++++++++

- Fix crashitem names mismatch between client and server.
(`#172 <https://github.com/pytest-dev/pytest-rerunfailures/issues/172>`_)

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Requirements

You will need the following prerequisites in order to use pytest-rerunfailures:

- Python 3.7, up to 3.11, or PyPy3
- pytest 6.0 or newer
- Python 3.7, up to 3.12, or PyPy3
- pytest 7.0 or newer

This plugin can recover from a hard crash with the following optional
prerequisites:
Expand Down
21 changes: 4 additions & 17 deletions pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
except ImportError:
HAS_PYTEST_HANDLECRASHITEM = False

PYTEST_GTE_63 = parse_version(pytest.__version__) >= parse_version("6.3.0")


def works_with_current_xdist():
"""Return compatibility with installed pytest-xdist version.
Expand Down Expand Up @@ -241,13 +239,7 @@ def _remove_failed_setup_state_from_session(item):
and clean the stack itself
"""
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 = []
setup_state.stack = {}


def _get_rerun_filter_regex(item, regex_name):
Expand Down Expand Up @@ -500,14 +492,9 @@ def pytest_runtest_teardown(item, nextitem):
_remove_cached_results_from_failed_fixtures(item)

if item in item.session._setupstate.stack:
if PYTEST_GTE_63:
for key in list(item.session._setupstate.stack.keys()):
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)
for key in list(item.session._setupstate.stack.keys()):
if key != item:
del item.session._setupstate.stack[key]


@pytest.hookimpl(hookwrapper=True)
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ignore =

[metadata]
name = pytest-rerunfailures
version = 12.1.dev0
version = 13.0.dev0
url = https://github.com/pytest-dev/pytest-rerunfailures
description = pytest plugin to re-run tests to eliminate flaky failures
long_description = file: HEADER.rst, README.rst, CHANGES.rst
Expand All @@ -32,6 +32,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Expand All @@ -42,7 +43,7 @@ py_modules = pytest_rerunfailures
python_requires = >= 3.7
install_requires =
packaging >= 17.1
pytest >= 6.2
pytest >= 7
importlib-metadata>=1;python_version<"3.8"

[options.entry_points]
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ max-line-length = 88
[tox]
envlist =
linting
py{37,38,39,310,311,py3}-pytest{62,70,71,72,73,74}
py{38,39,310,311,py3}-pytest{main}
py{37,38,39,310,311,312,py3}-pytest{70,71,72,73,74}
py{38,39,310,311,312,py3}-pytest{main}
minversion = 4.0

[testenv]
commands = pytest test_pytest_rerunfailures.py {posargs}
deps =
pytest-xdist
pytest62: pytest==6.2.*
pytest70: pytest==7.0.*
pytest71: pytest==7.1.*
pytest72: pytest==7.2.*
Expand Down

0 comments on commit fa7b4e4

Please sign in to comment.