diff --git a/changelog/4058.doc.rst b/changelog/4058.doc.rst new file mode 100644 index 000000000..51d568f54 --- /dev/null +++ b/changelog/4058.doc.rst @@ -0,0 +1 @@ +Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for. diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index d90850d09..fa111afa4 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -259,6 +259,11 @@ instance, you can simply declare it: Finally, the ``class`` scope will invoke the fixture once per test *class*. +.. note:: + + Pytest will only cache one instance of a fixture at a time. + This means that when using a parametrized fixture, pytest may invoke a fixture more than once in the given scope. + ``package`` scope (experimental) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^