1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Tue, 27 Feb 2024 10:20:14 +0100
Subject: Fix autopkgtest regression with pytest 9
---
conftest.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/conftest.py b/conftest.py
index f7ede3b..d6af93e 100644
--- a/conftest.py
+++ b/conftest.py
@@ -9,11 +9,9 @@ import pytest
import docopt
-def pytest_collect_file(path, parent):
- if path.ext == ".docopt" and path.basename.startswith("test"):
- if hasattr(DocoptTestFile, "from_parent"):
- return DocoptTestFile.from_parent(parent, fspath=path)
- return DocoptTestFile(path, parent)
+def pytest_collect_file(file_path, parent):
+ if file_path.suffix == ".docopt" and file_path.name.startswith("test"):
+ return DocoptTestFile.from_parent(parent, path=file_path)
def parse_test(raw):
@@ -37,11 +35,11 @@ def parse_test(raw):
class DocoptTestFile(pytest.File):
def collect(self):
- raw = self.fspath.open().read()
+ raw = self.path.open().read()
index = 1
for name, doc, cases in parse_test(raw):
- name = self.fspath.purebasename
+ name = self.path.name
for case in cases:
if hasattr(DocoptTestItem, "from_parent"):
yield DocoptTestItem.from_parent(self, name="%s(%d)" % (name, index), doc=doc, case=case)
@@ -78,7 +76,7 @@ class DocoptTestItem(pytest.Item):
))
def reportinfo(self):
- return self.fspath, 0, "usecase: %s" % self.name
+ return self.path, 0, "usecase: %s" % self.name
class DocoptTestException(Exception):
|