From dbc50a70610e1a2ff67b71fad2ef0813c5bce873 Mon Sep 17 00:00:00 2001 From: Kelton Bassingthwaite Date: Tue, 21 Jul 2020 20:00:47 -0600 Subject: [PATCH] Clarify usage of usefixtures mark in hooks Fix #7512 Co-authored-by: Bruno Oliveira --- changelog/7422.doc.rst | 1 + doc/en/reference.rst | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 changelog/7422.doc.rst diff --git a/changelog/7422.doc.rst b/changelog/7422.doc.rst new file mode 100644 index 000000000..105fb4be6 --- /dev/null +++ b/changelog/7422.doc.rst @@ -0,0 +1 @@ +Clarified when the ``usefixtures`` mark can apply fixtures to test. diff --git a/doc/en/reference.rst b/doc/en/reference.rst index 005014d84..828a2af27 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -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`: