Skip to content

Commit

Permalink
Bump min pytest to 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech committed Apr 4, 2024
1 parent fbf2eca commit 385ebd6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
1 change: 1 addition & 0 deletions changelog/1057.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest>=7.0.0 is now required.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classifiers = [
requires-python = ">=3.8"
dependencies = [
"execnet>=1.1",
"pytest>=6.2.0",
"pytest>=7.0.0",
]
dynamic = ["version"]

Expand Down
8 changes: 3 additions & 5 deletions src/xdist/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import pytest


PYTEST_GTE_7 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0) # type: ignore[attr-defined]

_sys_path = list(sys.path) # freeze a copy of sys.path at interpreter startup


Expand Down Expand Up @@ -188,16 +186,16 @@ def pytest_addoption(parser):
parser.addini(
"rsyncdirs",
"list of (relative) paths to be rsynced for remote distributed testing.",
type="paths" if PYTEST_GTE_7 else "pathlist",
type="paths",
)
parser.addini(
"rsyncignore",
"list of (relative) glob-style paths to be ignored for rsyncing.",
type="paths" if PYTEST_GTE_7 else "pathlist",
type="paths",
)
parser.addini(
"looponfailroots",
type="paths" if PYTEST_GTE_7 else "pathlist",
type="paths",
help="directories to check for changes. Default: current directory.",
)

Expand Down
28 changes: 8 additions & 20 deletions testing/test_looponfail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from xdist.looponfail import StatRecorder


PYTEST_GTE_7 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0) # type: ignore[attr-defined]


class TestStatRecorder:
def test_filechange(self, tmp_path: Path) -> None:
tmp = tmp_path
Expand Down Expand Up @@ -128,9 +125,8 @@ def test_failures_somewhere(self, pytester: pytest.Pytester) -> None:
failures = control.runsession()
assert failures
control.setup()
item_path = item.path if PYTEST_GTE_7 else Path(str(item.fspath)) # type: ignore[attr-defined]
item_path.write_text("def test_func():\n assert 1\n")
removepyc(item_path)
item.path.write_text("def test_func():\n assert 1\n")
removepyc(item.path)
topdir, failures = control.runsession()[:2]
assert not failures

Expand All @@ -146,10 +142,7 @@ def test_func():
control = RemoteControl(modcol.config)
control.loop_once()
assert control.failures
if PYTEST_GTE_7:
modcol_path = modcol.path # type:ignore[attr-defined]
else:
modcol_path = Path(str(modcol.fspath))
modcol_path = modcol.path # type:ignore[attr-defined]

modcol_path.write_text(
textwrap.dedent(
Expand Down Expand Up @@ -179,10 +172,7 @@ def test_func():
"""
)
)
if PYTEST_GTE_7:
parent = modcol.path.parent.parent # type: ignore[attr-defined]
else:
parent = Path(modcol.fspath.dirpath().dirpath())
parent = modcol.path.parent.parent # type: ignore[attr-defined]
monkeypatch.chdir(parent)
modcol.config.args = [
str(Path(x).relative_to(parent)) for x in modcol.config.args
Expand Down Expand Up @@ -248,8 +238,7 @@ def test_two():
remotecontrol.loop_once()
assert len(remotecontrol.failures) == 1

modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath)
modcol_path.write_text(
modcol.path.write_text(
textwrap.dedent(
"""
def test_one():
Expand All @@ -259,7 +248,7 @@ def test_two():
"""
)
)
removepyc(modcol_path)
removepyc(modcol.path)
remotecontrol.loop_once()
assert not remotecontrol.failures

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

modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath)
modcol_path.write_text(
modcol.path.write_text(
textwrap.dedent(
"""
def test_one():
Expand All @@ -288,7 +276,7 @@ def test_two():
"""
)
)
removepyc(modcol_path)
removepyc(modcol.path)
remotecontrol.loop_once()
assert len(remotecontrol.failures) == 0
remotecontrol.loop_once()
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ isolated_build = true
[testenv]
extras = testing
deps =
pytestmin: pytest==6.2.0
pytestmin: pytest==7.0.0
pytestlatest: pytest
pytestmain: git+https://github.com/pytest-dev/pytest.git
commands=
Expand Down

0 comments on commit 385ebd6

Please sign in to comment.