Skip to content

Commit b502a5e

Browse files
committed
Support pytest 9 changes
The old py.path arguments to the hook functions have been removed as of pytest 9, switch to the shiny new pathlib ones.
1 parent fd4f032 commit b502a5e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

html5lib/tests/conftest.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ def pytest_configure(config):
9090
pytest.exit("\n".join(msgs))
9191

9292

93-
def pytest_collect_file(path, parent):
94-
dir = os.path.abspath(path.dirname)
93+
def pytest_collect_file(file_path, parent):
94+
dir = file_path.parent
9595
dir_and_parents = set()
9696
while dir not in dir_and_parents:
9797
dir_and_parents.add(dir)
98-
dir = os.path.dirname(dir)
98+
dir = dir.parent
9999

100100
if _tree_construction in dir_and_parents:
101-
if path.ext == ".dat":
102-
return TreeConstructionFile.from_parent(parent, fspath=path)
101+
if file_path.suffix == ".dat":
102+
return TreeConstructionFile.from_parent(parent, path=file_path)
103103
elif _tokenizer in dir_and_parents:
104-
if path.ext == ".test":
105-
return TokenizerFile.from_parent(parent, fspath=path)
104+
if file_path.suffix == ".test":
105+
return TokenizerFile.from_parent(parent, path=file_path)
106106
elif _sanitizer_testdata in dir_and_parents:
107-
if path.ext == ".dat":
108-
return SanitizerFile.from_parent(parent, fspath=path)
107+
if file_path.suffix == ".dat":
108+
return SanitizerFile.from_parent(parent, path=file_path)
109109

110110

111111
# Tiny wrapper to allow .from_parent constructors on older pytest for PY27

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
flake8==3.9.2 ; python_version < '3.6'
44
flake8>=5.0.4; python_version >= '3.6'
55
pytest>=4.6.10,<5 ; python_version < '3'
6-
pytest>=5.4.2,<8 ; python_version >= '3'
6+
pytest>=7,<10 ; python_version >= '3'
77
coverage>=5.1,<6
88
pytest-expect>=1.1.0,<2
99
mock>=3.0.5,<4 ; python_version < '3.3'

0 commit comments

Comments
 (0)