diff --git a/changelog.d/+pytest_collection_path.changed.md b/changelog.d/+pytest_collection_path.changed.md new file mode 100644 index 00000000..1cb3d463 --- /dev/null +++ b/changelog.d/+pytest_collection_path.changed.md @@ -0,0 +1 @@ +Switch a pytest hook from path to collection_path. diff --git a/test/unit/conftest.py b/test/unit/conftest.py index 15929bae..e8305def 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -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