Skip to content

Commit

Permalink
Merge pull request #520 from selfisekai/conftest-collection_path
Browse files Browse the repository at this point in the history
pytest: switch hook from path to collection_path
  • Loading branch information
ppolewicz authored Nov 5, 2024
2 parents 4b403b9 + 74824aa commit 26f45a5
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 26f45a5

Please sign in to comment.