File: pytest6

package info (click to toggle)
docopt 0.6.2-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 324 kB
  • sloc: python: 1,042; makefile: 10
file content (28 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (2)
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
From: Michael R. Crusoe <crusoe@debian.org>
Subject: fix for pytest 6.x comptability
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=979285
Forwarded: https://github.com/docopt/docopt/pull/493

--- docopt.orig/conftest.py
+++ docopt/conftest.py
@@ -11,6 +11,8 @@
 
 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)
 
 
@@ -41,7 +43,10 @@
         for name, doc, cases in parse_test(raw):
             name = self.fspath.purebasename
             for case in cases:
-                yield DocoptTestItem("%s(%d)" % (name, index), self, doc, case)
+                if hasattr(DocoptTestItem, "from_parent"):
+                    yield DocoptTestItem.from_parent(self, name="%s(%d)" % (name, index), doc=doc, case=case)
+                else:
+                    yield DocoptTestItem("%s(%d)" % (name, index), self, doc, case)
                 index += 1