diff --git a/changelog/571.deprecation.rst b/changelog/571.deprecation.rst new file mode 100644 index 00000000000..1454e07eb9b --- /dev/null +++ b/changelog/571.deprecation.rst @@ -0,0 +1 @@ +Deprecate he unused/broken `pytest_collect_directory` hook. diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index db43c6ca3ef..df8ae16a831 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -49,3 +49,8 @@ "--no-print-logs is deprecated and scheduled for removal in pytest 6.0.\n" "Please use --show-capture instead." ) + +COLLECT_DIRECTORY_HOOK = PytestDeprecationWarning( + "the pytest_collect_directory was intended to be deprecated since 2014\n" + "as it's missaligned since the removal of Directory as collector in 2010" +) diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 62e2155a263..1e16d092d0b 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -4,6 +4,7 @@ from pluggy import HookspecMarker +from .deprecated import COLLECT_DIRECTORY_HOOK from _pytest.compat import TYPE_CHECKING if TYPE_CHECKING: @@ -205,7 +206,7 @@ def pytest_ignore_collect(path, config): """ -@hookspec(firstresult=True) +@hookspec(firstresult=True, warn_on_impl=COLLECT_DIRECTORY_HOOK) def pytest_collect_directory(path, parent): """ called before traversing a directory for collection files.