Clarify usage of usefixtures mark in hooks

Fix #7512

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
Kelton Bassingthwaite 2020-07-21 20:00:47 -06:00 committed by GitHub
parent 6ecb8f53d0
commit dbc50a7061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

1
changelog/7422.doc.rst Normal file
View File

@ -0,0 +1 @@
Clarified when the ``usefixtures`` mark can apply fixtures to test.

View File

@ -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`: