Deprecate pytest_collect_directory Fix #571 Co-authored-by: Daniel Hahler <github@thequod.de>
This commit is contained in:
parent
b11bfa106c
commit
9fd71d6fe0
|
@ -0,0 +1,3 @@
|
|||
Deprecate the unused/broken `pytest_collect_directory` hook.
|
||||
It was misaligned since the removal of the ``Directory`` collector in 2010
|
||||
and incorrect/unusable as soon as collection was split from test execution.
|
|
@ -49,3 +49,8 @@ NO_PRINT_LOGS = PytestDeprecationWarning(
|
|||
"--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 hook is not working.\n"
|
||||
"Please use collect_ignore in conftests or pytest_collection_modifyitems."
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ from typing import Optional
|
|||
|
||||
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.
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ class TestGeneralUsage:
|
|||
"E {}: No module named 'qwerty'".format(exc_name),
|
||||
]
|
||||
|
||||
@pytest.mark.filterwarnings("always::pytest.PytestDeprecationWarning")
|
||||
def test_early_skip(self, testdir):
|
||||
testdir.mkdir("xyz")
|
||||
testdir.makeconftest(
|
||||
|
|
|
@ -257,6 +257,7 @@ class TestCollectPluginHookRelay:
|
|||
assert len(wascalled) == 1
|
||||
assert wascalled[0].ext == ".abc"
|
||||
|
||||
@pytest.mark.filterwarnings("ignore:.*pytest_collect_directory.*")
|
||||
def test_pytest_collect_directory(self, testdir):
|
||||
wascalled = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue