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).
This commit is contained in:
parent
c8b4a1a471
commit
1d5a0ef284
|
@ -33,6 +33,7 @@ from _pytest.runner import SetupState
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
from _pytest.python import Package
|
from _pytest.python import Package
|
||||||
|
|
||||||
|
@ -293,7 +294,9 @@ def _in_venv(path):
|
||||||
return any([fname.basename in activates for fname in bindir.listdir()])
|
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 = config._getconftest_pathlist("collect_ignore", path=path.dirpath())
|
||||||
ignore_paths = ignore_paths or []
|
ignore_paths = ignore_paths or []
|
||||||
excludeopt = config.getoption("ignore")
|
excludeopt = config.getoption("ignore")
|
||||||
|
@ -317,8 +320,7 @@ def pytest_ignore_collect(path, config):
|
||||||
allow_in_venv = config.getoption("collect_in_virtualenv")
|
allow_in_venv = config.getoption("collect_in_virtualenv")
|
||||||
if not allow_in_venv and _in_venv(path):
|
if not allow_in_venv and _in_venv(path):
|
||||||
return True
|
return True
|
||||||
|
return None
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(items, config):
|
def pytest_collection_modifyitems(items, config):
|
||||||
|
|
Loading…
Reference in New Issue