Skip to content

Commit 3221560

Browse files
authored
Merge pull request #1330 from manics/pin-pytest
Support pytest=8
2 parents c806c1c + 56299a2 commit 3221560

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ build
22
conda-lock
33
pre-commit
44
pytest-cov
5-
pytest>=4.6
5+
pytest>=7
66
pyyaml
77
requests_mock

tests/conftest.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
TESTS_DIR = os.path.abspath(os.path.dirname(__file__))
3434

3535

36-
def pytest_collect_file(parent, path):
37-
if path.basename == "verify":
38-
return LocalRepo.from_parent(parent, fspath=path)
39-
elif path.basename.endswith(".repos.yaml"):
40-
return RemoteRepoList.from_parent(parent, fspath=path)
36+
def pytest_collect_file(parent, file_path):
37+
if file_path.name == "verify":
38+
return LocalRepo.from_parent(parent, path=file_path)
39+
elif file_path.name.endswith(".repos.yaml"):
40+
return RemoteRepoList.from_parent(parent, path=file_path)
4141

4242

4343
def make_test_func(args, skip_build=False, extra_run_kwargs=None):
@@ -213,7 +213,7 @@ def __init__(
213213
super().__init__(name, parent, callobj=f)
214214

215215
def reportinfo(self):
216-
return (self.parent.fspath, None, "")
216+
return (self.parent.path, None, "")
217217

218218
def repr_failure(self, excinfo):
219219
err = excinfo.value
@@ -233,24 +233,23 @@ def collect(self):
233233
args = ["--appendix", 'RUN echo "appendix" > /tmp/appendix']
234234
# If there's an extra-args.yaml file in a test dir, assume it contains
235235
# a yaml list with extra arguments to be passed to repo2docker
236-
extra_args_path = os.path.join(self.fspath.dirname, "test-extra-args.yaml")
237-
if os.path.exists(extra_args_path):
238-
with open(extra_args_path) as f:
239-
extra_args = yaml.safe_load(f)
236+
extra_args_path = self.path.parent / "test-extra-args.yaml"
237+
if extra_args_path.exists():
238+
extra_args = yaml.safe_load(extra_args_path.read_text())
240239
args += extra_args
241240

242-
print(self.fspath.basename, self.fspath.dirname, str(self.fspath))
241+
print(self.path.name, self.path.parent, str(self.path))
243242
# re-use image name for multiple tests of the same image
244243
# so we don't run through the build twice
245-
rel_repo_dir = os.path.relpath(self.fspath.dirname, TESTS_DIR)
244+
rel_repo_dir = os.path.relpath(self.path.parent, TESTS_DIR)
246245
image_name = f"r2d-tests-{escapism.escape(rel_repo_dir, escape_char='-').lower()}-{int(time.time())}"
247246
args.append(f"--image-name={image_name}")
248-
args.append(self.fspath.dirname)
247+
args.append(str(self.path.parent))
249248
yield Repo2DockerTest.from_parent(self, name="build", args=args)
250249

251250
yield Repo2DockerTest.from_parent(
252251
self,
253-
name=self.fspath.basename,
252+
name=self.path.name,
254253
args=args + ["./verify"],
255254
skip_build=True,
256255
)
@@ -273,7 +272,7 @@ def collect(self):
273272

274273
class RemoteRepoList(pytest.File):
275274
def collect(self):
276-
with self.fspath.open() as f:
275+
with self.path.open() as f:
277276
repos = yaml.safe_load(f)
278277
for repo in repos:
279278
args = []

0 commit comments

Comments
 (0)