File: 0003-Fix-deprecated-py.path.local-usage.patch

package info (click to toggle)
html5lib 1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,484 kB
  • sloc: python: 13,014; sh: 10; makefile: 7
file content (63 lines) | stat: -rw-r--r-- 2,476 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Mon, 22 Dec 2025 10:49:00 +0100
Subject: Fix deprecated py.path.local usage

---
 html5lib/tests/conftest.py | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py
index de9b157..de76e98 100644
--- a/html5lib/tests/conftest.py
+++ b/html5lib/tests/conftest.py
@@ -8,12 +8,13 @@ from .tree_construction import TreeConstructionFile
 from .tokenizer import TokenizerFile
 from .sanitizer import SanitizerFile
 
-_dir = os.path.abspath(os.path.dirname(__file__))
-_root = os.path.join(_dir, "..", "..")
-_testdata = os.path.join(_dir, "testdata")
-_tree_construction = os.path.join(_testdata, "tree-construction")
-_tokenizer = os.path.join(_testdata, "tokenizer")
-_sanitizer_testdata = os.path.join(_dir, "sanitizer-testdata")
+from pathlib import Path
+_dir = Path(__file__).absolute().parent
+_root = _dir.parent.parent
+_testdata = _dir / "testdata"
+_tree_construction = _testdata / "tree-construction"
+_tokenizer = _testdata / "tokenizer"
+_sanitizer_testdata = _dir / "sanitizer-testdata"
 
 
 def fail_if_missing_pytest_expect():
@@ -89,22 +90,18 @@ def pytest_configure(config):
         pytest.exit("\n".join(msgs))
 
 
-def pytest_collect_file(path, parent):
-    dir = os.path.abspath(path.dirname)
-    dir_and_parents = set()
-    while dir not in dir_and_parents:
-        dir_and_parents.add(dir)
-        dir = os.path.dirname(dir)
+def pytest_collect_file(file_path, parent):
+    dir_and_parents = file_path.absolute().parents
 
     if _tree_construction in dir_and_parents:
-        if path.ext == ".dat":
-            return TreeConstructionFile.from_parent(parent, fspath=path)
+        if file_path.suffix == ".dat":
+            return TreeConstructionFile.from_parent(parent, path=file_path)
     elif _tokenizer in dir_and_parents:
-        if path.ext == ".test":
-            return TokenizerFile.from_parent(parent, fspath=path)
+        if file_path.suffix == ".test":
+            return TokenizerFile.from_parent(parent, path=file_path)
     elif _sanitizer_testdata in dir_and_parents:
-        if path.ext == ".dat":
-            return SanitizerFile.from_parent(parent, fspath=path)
+        if file_path.suffix == ".dat":
+            return SanitizerFile.from_parent(parent, path=file_path)
 
 
 # Tiny wrapper to allow .from_parent constructors on older pytest for PY27