Skip to content

Commit ae17c61

Browse files
authored
Fix tests on pytest 9 (#4835)
Fixes #4826
1 parent 138745e commit ae17c61

File tree

5 files changed

+6
-20
lines changed

5 files changed

+6
-20
lines changed

.github/workflows/pypi_upload.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ jobs:
9696
- uses: pypa/cibuildwheel@v3.2.1
9797
with:
9898
only: ${{ matrix.only }}
99-
env:
100-
CIBW_TEST_REQUIRES_WINDOWS: "pytest^<9.0"
10199

102100
- name: Upload wheels as workflow artifacts
103101
uses: actions/upload-artifact@v5

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ skip = [
168168
# This is the bare minimum needed to run the test suite. Pulling in the full
169169
# test_requirements.txt would download a bunch of other packages not necessary
170170
# here and would slow down the testing step a fair bit.
171-
test-requires = ["pytest>=6.1.1,<9.0"]
171+
test-requires = ["pytest>=7"]
172172
test-command = 'pytest {project} -k "not incompatible_with_mypyc"'
173173
test-extras = ["d"," jupyter"]
174174
# Skip trying to test arm64 builds on Intel Macs. (so cross-compilation doesn't

test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
coverage >= 5.3
22
pre-commit
3-
pytest >= 6.1.1, <9.0
3+
pytest >= 7
44
pytest-xdist >= 3.0.2
55
pytest-cov >= 4.1.0
66
tox

tests/optional.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,7 @@
2121
from typing import TYPE_CHECKING
2222

2323
import pytest
24-
25-
try:
26-
from pytest import StashKey
27-
except ImportError:
28-
# pytest < 7
29-
#
30-
# "isort: skip" is needed or it moves the "type: ignore" to the following line
31-
# because of the line length, and then mypy complains.
32-
# Of course, adding the "isort: skip" means that
33-
# flake8-bugbear then also complains about the line length,
34-
# so we *also* need a "noqa" comment for good measure :)
35-
from _pytest.store import ( # type: ignore[import-not-found, no-redef] # isort: skip # noqa: B950
36-
StoreKey as StashKey,
37-
)
24+
from pytest import StashKey
3825

3926
log = logging.getLogger(__name__)
4027

@@ -73,7 +60,8 @@ def pytest_configure(config: "Config") -> None:
7360
if isinstance(ot_ini, str):
7461
ot_ini = ot_ini.strip().split("\n")
7562
marker_re = re.compile(r"^\s*(?P<no>no_)?(?P<marker>\w+)(:\s*(?P<description>.*))?")
76-
for ot in ot_ini:
63+
# getattr shim here is so that we support both pytest>=9 and pytest<9
64+
for ot in getattr(ot_ini, "value", ot_ini):
7765
m = marker_re.match(ot)
7866
if not m:
7967
raise ValueError(f"{ot!r} doesn't match pytest marker syntax")

tests/test_black.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ def test_get_features_used_for_future_flags(self) -> None:
922922
("a = 1 + 2\nfrom something import annotations", set()),
923923
("from __future__ import x, y", set()),
924924
]:
925-
with self.subTest(src=src, features=features):
925+
with self.subTest(src=src, features=sorted(f.value for f in features)):
926926
node = black.lib2to3_parse(src)
927927
future_imports = black.get_future_imports(node)
928928
self.assertEqual(

0 commit comments

Comments
 (0)