From 1d5a0ef2849c1d317030be696419f8751eccd1c5 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 22 Feb 2020 23:35:47 +0100 Subject: [PATCH] Fix pytest_ignore_collect hooks: do not return False (#6778) It should only return `True` when something is to be ignored, not `False` otherwise typically. This caused e.g. bad interaction with the cacheprovider (before https://github.com/pytest-dev/pytest/pull/6448). --- src/_pytest/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index f6cb17091..b0386bc65 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -33,6 +33,7 @@ from _pytest.runner import SetupState if TYPE_CHECKING: from typing import Type + from typing_extensions import Literal from _pytest.python import Package @@ -293,7 +294,9 @@ def _in_venv(path): return any([fname.basename in activates for fname in bindir.listdir()]) -def pytest_ignore_collect(path, config): +def pytest_ignore_collect( + path: py.path.local, config: Config +) -> "Optional[Literal[True]]": ignore_paths = config._getconftest_pathlist("collect_ignore", path=path.dirpath()) ignore_paths = ignore_paths or [] excludeopt = config.getoption("ignore") @@ -317,8 +320,7 @@ def pytest_ignore_collect(path, config): allow_in_venv = config.getoption("collect_in_virtualenv") if not allow_in_venv and _in_venv(path): return True - - return False + return None def pytest_collection_modifyitems(items, config):