Skip to content

Commit

Permalink
pytest: switch hook from path to collection_path
Browse files Browse the repository at this point in the history
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
  • Loading branch information
selfisekai committed Oct 30, 2024
1 parent 79c5793 commit 74824aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/+pytest_collection_path.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch a pytest hook from path to collection_path.
5 changes: 2 additions & 3 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ def pytest_report_header(config):


@pytest.hookimpl(tryfirst=True)
def pytest_ignore_collect(path, config):
def pytest_ignore_collect(collection_path, config):
"""Ignore all tests from subfolders for different apiver."""
path = str(path)
ver = config.getoption('--api')
other_versions = [v for v in API_VERSIONS if v != ver]
for other_version in other_versions:
if other_version + os.sep in path:
if other_version in collection_path.parts:
return True
return False

Expand Down

0 comments on commit 74824aa

Please sign in to comment.