Skip to content

Commit ae58690

Browse files
committed
Avoid soft-deprecated pathlist ini type on pytest>=7
This allows the test suite to succeed with the legacypath plugin blocked. Fix #722.
1 parent d794b27 commit ae58690

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

changelog/722.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Full compatibility with pytest 7 - no deprecation warnings or use of legacy features.

src/xdist/looponfail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def pytest_cmdline_main(config):
3838

3939
def looponfail_main(config):
4040
remotecontrol = RemoteControl(config)
41-
rootdirs = config.getini("looponfailroots")
41+
rootdirs = [py.path.local(root) for root in config.getini("looponfailroots")]
4242
statrecorder = StatRecorder(rootdirs)
4343
try:
4444
while 1:

src/xdist/plugin.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import os
22
import uuid
33
import sys
4+
from pathlib import Path
45

56
import py
67
import pytest
78

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

1014

@@ -147,18 +151,18 @@ def pytest_addoption(parser):
147151
parser.addini(
148152
"rsyncdirs",
149153
"list of (relative) paths to be rsynced for remote distributed testing.",
150-
type="pathlist",
154+
type="paths" if PYTEST_GTE_7 else "pathlist",
151155
)
152156
parser.addini(
153157
"rsyncignore",
154158
"list of (relative) glob-style paths to be ignored for rsyncing.",
155-
type="pathlist",
159+
type="paths" if PYTEST_GTE_7 else "pathlist",
156160
)
157161
parser.addini(
158162
"looponfailroots",
159-
type="pathlist",
163+
type="paths" if PYTEST_GTE_7 else "pathlist",
160164
help="directories to check for changes",
161-
default=[py.path.local()],
165+
default=[Path.cwd() if PYTEST_GTE_7 else py.path.local()],
162166
)
163167

164168

src/xdist/workermanage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def get_dir(p):
118118
def _getrsyncoptions(self):
119119
"""Get options to be passed for rsync."""
120120
ignores = list(self.DEFAULT_IGNORES)
121-
ignores += self.config.option.rsyncignore
122-
ignores += self.config.getini("rsyncignore")
121+
ignores += [str(path) for path in self.config.option.rsyncignore]
122+
ignores += [str(path) for path in self.config.getini("rsyncignore")]
123123

124124
return {
125125
"ignores": ignores,

0 commit comments

Comments
 (0)