Files
gentoo/dev-python/docopt/files/docopt-0.6.2-pytest9.patch
Alfred Wingate 7fb9e397ef dev-python/docopt: fix tests against pytest-9
Closes: https://bugs.gentoo.org/977828
Signed-off-by: Alfred Wingate <parona@protonmail.com>
Signed-off-by: Sam James <sam@gentoo.org>
2026-07-19 16:30:14 +01:00

55 lines
1.7 KiB
Diff

https://bugs.gentoo.org/977828
https://github.com/docopt/docopt/pull/532
From 71351363b175aa643b75a73faeeb7772b32155ef Mon Sep 17 00:00:00 2001
From: Amaury Forgeot d'Arc <amauryfa@gmail.com>
Date: Fri, 12 Jun 2026 15:24:57 +0000
Subject: [PATCH] Adapt conftest for pytest 9.0.0: pytest_collect_file now
takes a pathlib.Path
--- a/conftest.py
+++ b/conftest.py
@@ -9,9 +9,9 @@
import docopt
-def pytest_collect_file(path, parent):
- if path.ext == ".docopt" and path.basename.startswith("test"):
- 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(path=file_path, parent=parent)
def parse_test(raw):
@@ -35,22 +35,24 @@ def parse_test(raw):
class DocoptTestFile(pytest.File):
def collect(self):
- raw = self.fspath.open().read()
+ raw = self.path.read_text()
index = 1
for name, doc, cases in parse_test(raw):
- name = self.fspath.purebasename
+ name = self.path.stem
for case in cases:
- yield DocoptTestItem("%s(%d)" % (name, index), self, doc, case)
+ yield DocoptTestItem.from_parent(self, name="%s(%d)" % (name, index), doc=doc, case=case)
index += 1
class DocoptTestItem(pytest.Item):
- def __init__(self, name, parent, doc, case):
- super(DocoptTestItem, self).__init__(name, parent)
+ @classmethod
+ def from_parent(cls, parent, name, doc, case):
+ self = super().from_parent(parent, name=name)
self.doc = doc
self.prog, self.argv, self.expect = case
+ return self
def runtest(self):
try: