From 642847c0793d4aed393b78317fc32a295695cfc7 Mon Sep 17 00:00:00 2001 From: Jeffrey Rackauckas Date: Tue, 2 Oct 2018 20:53:15 -0700 Subject: [PATCH 1/2] Update documentation on fixture being invoked more than once in a scope. --- changelog/4058.doc.rst | 1 + doc/en/fixture.rst | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 changelog/4058.doc.rst 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 e48e055fe..1628d0208 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, it may need to be invoked more than once in the scope it's defined for. + ``package`` scope (experimental) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From c5dec6056f69ac39cccf982af2524561566b554a Mon Sep 17 00:00:00 2001 From: Jeffrey Rackauckas Date: Tue, 2 Oct 2018 21:17:53 -0700 Subject: [PATCH 2/2] Fix wording in fixtures doc. --- doc/en/fixture.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 1628d0208..65664c0b2 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -262,7 +262,7 @@ 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, it may need to be invoked more than once in the scope it's defined for. + This means that when using a parametrized fixture, pytest may invoke a fixture more than once in the given scope. ``package`` scope (experimental)