Skip to content

Commit 26f45a5

Browse files
authored
Merge pull request #520 from selfisekai/conftest-collection_path
pytest: switch hook from path to collection_path
2 parents 4b403b9 + 74824aa commit 26f45a5

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)