Skip to content

Commit 74824aa

Browse files
committed
pytest: switch hook from path to collection_path
solves PytestRemovedIn9Warning: The (path: py.path.local) argument is deprecated, please use (collection_path: pathlib.Path) https://docs.pytest.org/en/latest/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path
1 parent 79c5793 commit 74824aa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switch a pytest hook from path to collection_path.

test/unit/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ def pytest_report_header(config):
6464

6565

6666
@pytest.hookimpl(tryfirst=True)
67-
def pytest_ignore_collect(path, config):
67+
def pytest_ignore_collect(collection_path, config):
6868
"""Ignore all tests from subfolders for different apiver."""
69-
path = str(path)
7069
ver = config.getoption('--api')
7170
other_versions = [v for v in API_VERSIONS if v != ver]
7271
for other_version in other_versions:
73-
if other_version + os.sep in path:
72+
if other_version in collection_path.parts:
7473
return True
7574
return False
7675

0 commit comments

Comments
 (0)