Skip to content

Commit 385ebd6

Browse files
committed
Bump min pytest to 7.0.0
Refs pytest-dev#1057
1 parent fbf2eca commit 385ebd6

File tree

5 files changed

+14
-27
lines changed

5 files changed

+14
-27
lines changed

changelog/1057.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest>=7.0.0 is now required.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ classifiers = [
3434
requires-python = ">=3.8"
3535
dependencies = [
3636
"execnet>=1.1",
37-
"pytest>=6.2.0",
37+
"pytest>=7.0.0",
3838
]
3939
dynamic = ["version"]
4040

src/xdist/plugin.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import pytest
77

88

9-
PYTEST_GTE_7 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0) # type: ignore[attr-defined]
10-
119
_sys_path = list(sys.path) # freeze a copy of sys.path at interpreter startup
1210

1311

@@ -188,16 +186,16 @@ def pytest_addoption(parser):
188186
parser.addini(
189187
"rsyncdirs",
190188
"list of (relative) paths to be rsynced for remote distributed testing.",
191-
type="paths" if PYTEST_GTE_7 else "pathlist",
189+
type="paths",
192190
)
193191
parser.addini(
194192
"rsyncignore",
195193
"list of (relative) glob-style paths to be ignored for rsyncing.",
196-
type="paths" if PYTEST_GTE_7 else "pathlist",
194+
type="paths",
197195
)
198196
parser.addini(
199197
"looponfailroots",
200-
type="paths" if PYTEST_GTE_7 else "pathlist",
198+
type="paths",
201199
help="directories to check for changes. Default: current directory.",
202200
)
203201

testing/test_looponfail.py

+8-20
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
from xdist.looponfail import StatRecorder
1313

1414

15-
PYTEST_GTE_7 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0) # type: ignore[attr-defined]
16-
17-
1815
class TestStatRecorder:
1916
def test_filechange(self, tmp_path: Path) -> None:
2017
tmp = tmp_path
@@ -128,9 +125,8 @@ def test_failures_somewhere(self, pytester: pytest.Pytester) -> None:
128125
failures = control.runsession()
129126
assert failures
130127
control.setup()
131-
item_path = item.path if PYTEST_GTE_7 else Path(str(item.fspath)) # type: ignore[attr-defined]
132-
item_path.write_text("def test_func():\n assert 1\n")
133-
removepyc(item_path)
128+
item.path.write_text("def test_func():\n assert 1\n")
129+
removepyc(item.path)
134130
topdir, failures = control.runsession()[:2]
135131
assert not failures
136132

@@ -146,10 +142,7 @@ def test_func():
146142
control = RemoteControl(modcol.config)
147143
control.loop_once()
148144
assert control.failures
149-
if PYTEST_GTE_7:
150-
modcol_path = modcol.path # type:ignore[attr-defined]
151-
else:
152-
modcol_path = Path(str(modcol.fspath))
145+
modcol_path = modcol.path # type:ignore[attr-defined]
153146

154147
modcol_path.write_text(
155148
textwrap.dedent(
@@ -179,10 +172,7 @@ def test_func():
179172
"""
180173
)
181174
)
182-
if PYTEST_GTE_7:
183-
parent = modcol.path.parent.parent # type: ignore[attr-defined]
184-
else:
185-
parent = Path(modcol.fspath.dirpath().dirpath())
175+
parent = modcol.path.parent.parent # type: ignore[attr-defined]
186176
monkeypatch.chdir(parent)
187177
modcol.config.args = [
188178
str(Path(x).relative_to(parent)) for x in modcol.config.args
@@ -248,8 +238,7 @@ def test_two():
248238
remotecontrol.loop_once()
249239
assert len(remotecontrol.failures) == 1
250240

251-
modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath)
252-
modcol_path.write_text(
241+
modcol.path.write_text(
253242
textwrap.dedent(
254243
"""
255244
def test_one():
@@ -259,7 +248,7 @@ def test_two():
259248
"""
260249
)
261250
)
262-
removepyc(modcol_path)
251+
removepyc(modcol.path)
263252
remotecontrol.loop_once()
264253
assert not remotecontrol.failures
265254

@@ -277,8 +266,7 @@ def test_one():
277266
assert len(remotecontrol.failures) == 1
278267
assert "test_one" in remotecontrol.failures[0]
279268

280-
modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath)
281-
modcol_path.write_text(
269+
modcol.path.write_text(
282270
textwrap.dedent(
283271
"""
284272
def test_one():
@@ -288,7 +276,7 @@ def test_two():
288276
"""
289277
)
290278
)
291-
removepyc(modcol_path)
279+
removepyc(modcol.path)
292280
remotecontrol.loop_once()
293281
assert len(remotecontrol.failures) == 0
294282
remotecontrol.loop_once()

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ isolated_build = true
99
[testenv]
1010
extras = testing
1111
deps =
12-
pytestmin: pytest==6.2.0
12+
pytestmin: pytest==7.0.0
1313
pytestlatest: pytest
1414
pytestmain: git+https://github.com/pytest-dev/pytest.git
1515
commands=

0 commit comments

Comments
 (0)