From 7c3ad725d779023870ab0ba8c1424100569914e4 Mon Sep 17 00:00:00 2001 From: Joshua Vetos Date: Mon, 14 Sep 2026 11:10:03 -0500 Subject: [PATCH 1/2] docs: clarify package-scoped fixture boundaries Co-authored-by: ChatGPT --- changelog/13216.doc.rst | 1 + doc/en/how-to/fixtures.rst | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/13216.doc.rst diff --git a/changelog/13216.doc.rst b/changelog/13216.doc.rst new file mode 100644 index 00000000000..18e3b3e6810 --- /dev/null +++ b/changelog/13216.doc.rst @@ -0,0 +1 @@ +Clarified that ``package``-scoped fixtures use pytest package collection boundaries, which by default require an ``__init__.py`` file. diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index 0ffc0778f9f..efec300026d 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -496,7 +496,11 @@ Fixtures are created when first requested by a test, and are destroyed based on * ``function``: the default scope, the fixture is destroyed at the end of the test. * ``class``: the fixture is destroyed during teardown of the last test in the class. * ``module``: the fixture is destroyed during teardown of the last test in the module. -* ``package``: the fixture is destroyed during teardown of the last test in the package where the fixture is defined, including sub-packages and sub-directories within it. +* ``package``: the fixture is destroyed during teardown of the last test in the + package where the fixture is defined, including sub-packages and + sub-directories within it. Here, a package is a directory collected by pytest + as a :class:`~pytest.Package`, which by default requires an ``__init__.py`` + file. * ``session``: the fixture is destroyed at the end of the test session. .. note:: From d7e719f142bba76eb920f94e9ba688050c3f5342 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 15 Sep 2026 14:49:23 -0500 Subject: [PATCH 2/2] Update doc/en/how-to/fixtures.rst Co-authored-by: Ran Benita --- doc/en/how-to/fixtures.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index efec300026d..4d7ba3c0aa5 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -497,10 +497,8 @@ Fixtures are created when first requested by a test, and are destroyed based on * ``class``: the fixture is destroyed during teardown of the last test in the class. * ``module``: the fixture is destroyed during teardown of the last test in the module. * ``package``: the fixture is destroyed during teardown of the last test in the - package where the fixture is defined, including sub-packages and - sub-directories within it. Here, a package is a directory collected by pytest - as a :class:`~pytest.Package`, which by default requires an ``__init__.py`` - file. + :term:`regular ` :ref:`Python package ` where the fixture is defined, including sub-packages and + sub-directories within it. * ``session``: the fixture is destroyed at the end of the test session. .. note::