Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/11307.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document that ``@pytest.hookimpl(specname=...)`` only works for function names starting with ``pytest_``.
10 changes: 10 additions & 0 deletions doc/en/how-to/writing_hook_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ Here is the order of execution:
It's possible to use ``tryfirst`` and ``trylast`` also on hook wrappers
in which case it will influence the ordering of hook wrappers among each other.

.. note::

pytest only searches for hook implementations whose names start with
``pytest_``. The ``specname`` argument to ``@pytest.hookimpl`` can be used
to give an implementation a different suffix, for example
``pytest_collection_modifyitems_tryfirst``, but the function name still
needs to start with ``pytest_``. A hook implementation named
``my_collection_modifyitems`` is ignored even if it is decorated with
``@pytest.hookimpl(specname="pytest_collection_modifyitems")``.

.. _`declaringhooks`:

Declaring new hooks
Expand Down
Loading