Skip to content

Commit 3fb43e2

Browse files
committed
Pytest 8 compatibility
Fixes #15
1 parent 8c4b2bc commit 3fb43e2

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.github/workflows/test.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ jobs:
5656
- "3.8"
5757
- "pypy3.9"
5858
pytest-version:
59-
- "pytest<7"
6059
- "pytest<8"
60+
- "pytest<9"
6161
- "pytest"
62+
- "git+https://github.com/pytest-dev/pytest.git@main"
6263
runs-on: ubuntu-latest
6364
steps:
6465
- uses: actions/checkout@v3

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22

33

4+
## [0.6.0] - 2024-03-13
5+
- Add Pytest 8 support
6+
- Add Python 3.12 support
7+
- Drop Pytest 6 support
8+
- Drop Python 3.7 support
9+
10+
411
## [0.5.2] - 2022-11-28
512
- Reorder items on __eq__ for better diff
613

pytest_unordered/__init__.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Optional
77
from typing import Tuple
88

9+
import pytest
910
from _pytest._io.saferepr import saferepr
1011
from _pytest.assertion.util import _compare_eq_any
1112
from _pytest.config import Config
@@ -93,7 +94,19 @@ def pytest_assertrepr_compare(
9394
extra_left, extra_right = _compare_eq_unordered(left, right)
9495
if len(extra_left) == 1 and len(extra_right) == 1:
9596
result.append("One item replaced:")
96-
result.extend(_compare_eq_any(extra_left[0], extra_right[0], verbose))
97+
if pytest.version_tuple < (8, 0, 0):
98+
result.extend(
99+
_compare_eq_any(extra_left[0], extra_right[0], verbose=verbose) # type: ignore
100+
)
101+
else:
102+
result.extend(
103+
_compare_eq_any(
104+
extra_left[0],
105+
extra_right[0],
106+
highlighter=config.get_terminal_writer()._highlight,
107+
verbose=verbose,
108+
)
109+
)
97110
else:
98111
if extra_left:
99112
result.append("Extra items in the left sequence:")

0 commit comments

Comments
 (0)