File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ Joshua Bronson
151
151
Jurko Gospodnetić
152
152
Justyna Janczyszyn
153
153
Kale Kundert
154
+ Kamran Ahmad
154
155
Karl O. Pinc
155
156
Katarzyna Jachim
156
157
Katarzyna Król
Original file line number Diff line number Diff line change @@ -614,6 +614,11 @@ among each other.
614
614
Declaring new hooks
615
615
------------------------
616
616
617
+ .. note ::
618
+
619
+ This is a quick overview on how to add new hooks and how they work in general, but a more complete
620
+ overview can be found in `the pluggy documentation <https://pluggy.readthedocs.io/en/latest/ >`__.
621
+
617
622
.. currentmodule :: _pytest.hookspec
618
623
619
624
Plugins and ``conftest.py `` files may declare new hooks that can then be
@@ -627,7 +632,7 @@ Hooks are usually declared as do-nothing functions that contain only
627
632
documentation describing when the hook will be called and what return values
628
633
are expected. The names of the functions must start with `pytest_ ` otherwise pytest won't recognize them.
629
634
630
- Here's an example. Let's assume this code is in the ``hooks .py `` module.
635
+ Here's an example. Let's assume this code is in the ``sample_hook .py `` module.
631
636
632
637
.. code-block :: python
633
638
@@ -643,10 +648,10 @@ class or module can then be passed to the ``pluginmanager`` using the ``pytest_a
643
648
.. code-block :: python
644
649
645
650
def pytest_addhooks (pluginmanager ):
646
- """ This example assumes the hooks are grouped in the 'hooks ' module. """
647
- from my_app.tests import hooks
651
+ """ This example assumes the hooks are grouped in the 'sample_hook ' module. """
652
+ from my_app.tests import sample_hook
648
653
649
- pluginmanager.add_hookspecs(hooks )
654
+ pluginmanager.add_hookspecs(sample_hook )
650
655
651
656
For a real world example, see `newhooks.py `_ from `xdist <https://github.com/pytest-dev/pytest-xdist >`_.
652
657
You can’t perform that action at this time.
0 commit comments