From 1c53caac1c98e33b113463149c01d835730a814f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 3 Nov 2024 12:55:20 +0100 Subject: [PATCH] Fixed `pytest_ignore_collect` not to block default pytest code (#464) Fixed `pytest_ignore_collect` hook implementation to return `None` rather than `False` when the path ought not to be ignored. This is necessary to enable the default pytest implementation of `pytest_ignore_collect()` to be used. Otherwise, the default rules are never applied and e.g. `--ignore` does not work. --- docs/versionhistory.rst | 3 +++ tests/conftest.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 0bba890..770fd27 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -22,6 +22,9 @@ This library adheres to - Fixed checks against annotations wrapped in ``NotRequired`` not being run unless the ``NotRequired`` is a forward reference (`#454 `_) +- Fixed the ``pytest_ignore_collect`` hook in the pytest plugin blocking default pytest + collection ignoring behavior by returning ``None`` instead of ``False`` + (PR by @mgorny) **4.4.0** (2024-10-27) diff --git a/tests/conftest.py b/tests/conftest.py index 3a0f3ea..ef8731f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,14 +13,16 @@ pytest_plugins = ["pytester"] -def pytest_ignore_collect(collection_path: Path, config: pytest.Config) -> bool: +def pytest_ignore_collect( + collection_path: Path, config: pytest.Config +) -> typing.Optional[bool]: match = version_re.search(collection_path.name) if match: version = tuple(int(x) for x in match.groups()) if sys.version_info < version: return True - return False + return None @pytest.fixture