Skip to content

Commit

Permalink
Clarify usage of usefixtures mark in hooks
Browse files Browse the repository at this point in the history
Fix #7512

Co-authored-by: Bruno Oliveira <[email protected]>
  • Loading branch information
KGB33 and nicoddemus authored Jul 22, 2020
1 parent 6ecb8f5 commit dbc50a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog/7422.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarified when the ``usefixtures`` mark can apply fixtures to test.
13 changes: 8 additions & 5 deletions doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ pytest.mark.usefixtures

Mark a test function as using the given fixture names.

.. warning::

This mark has no effect when applied
to a **fixture** function.

.. py:function:: pytest.mark.usefixtures(*names)
:param args: the names of the fixture to use, as strings

.. note::

When using `usefixtures` in hooks, it can only load fixtures when applied to a test function before test setup
(for example in the `pytest_collection_modifyitems` hook).

Also not that his mark has no effect when applied to **fixtures**.



.. _`pytest.mark.xfail ref`:

Expand Down

0 comments on commit dbc50a7

Please sign in to comment.