Skip to content

Commit 289197f

Browse files
committed
Remove package scope experimental status
Close #7389
1 parent 7450b6d commit 289197f

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

changelog/7389.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixture scope ``package`` is no longer considered experimental.

doc/en/fixture.rst

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ and `pytest-datafiles <https://pypi.org/project/pytest-datafiles/>`__.
244244

245245
.. _smtpshared:
246246

247-
Scope: sharing a fixture instance across tests in a class, module or session
248-
----------------------------------------------------------------------------
247+
Scope: sharing fixtures across classes, modules, packages or session
248+
--------------------------------------------------------------------
249249

250250
.. regendoc:wipe
251251
@@ -356,29 +356,23 @@ instance, you can simply declare it:
356356
# all tests needing it
357357
...
358358
359-
Finally, the ``class`` scope will invoke the fixture once per test *class*.
360359
361-
.. note::
362-
363-
Pytest will only cache one instance of a fixture at a time.
364-
This means that when using a parametrized fixture, pytest may invoke a fixture more than once in the given scope.
365-
366-
367-
``package`` scope (experimental)
368-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
360+
Fixture scopes
361+
^^^^^^^^^^^^^^
369362

363+
Fixtures are created when first requested by a test, and are destroyed based on their ``scope``:
370364

365+
* ``function``: the default scope, the fixture is destroyed at the end of the test.
366+
* ``class``: the fixture is destroyed during teardown of the last test in the class.
367+
* ``module``: the fixture is destroyed during teardown of the last test in the module.
368+
* ``package``: the fixture is destroyed during teardown of the last test in the package.
369+
* ``session``: the fixture is destroyed at the end of the test session.
371370

372-
In pytest 3.7 the ``package`` scope has been introduced. Package-scoped fixtures
373-
are finalized when the last test of a *package* finishes.
374-
375-
.. warning::
376-
This functionality is considered **experimental** and may be removed in future
377-
versions if hidden corner-cases or serious problems with this functionality
378-
are discovered after it gets more usage in the wild.
379-
380-
Use this new feature sparingly and please make sure to report any issues you find.
371+
.. note::
381372

373+
Pytest only caches one instance of a fixture at a time, which
374+
means that when using a parametrized fixture, pytest may invoke a fixture more than once in
375+
the given scope.
382376

383377
.. _dynamic scope:
384378

src/_pytest/fixtures.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,7 @@ def fixture( # noqa: F811
12741274
12751275
:arg scope: the scope for which this fixture is shared, one of
12761276
``"function"`` (default), ``"class"``, ``"module"``,
1277-
``"package"`` or ``"session"`` (``"package"`` is considered **experimental**
1278-
at this time).
1277+
``"package"`` or ``"session"``.
12791278
12801279
This parameter may also be a callable which receives ``(fixture_name, config)``
12811280
as parameters, and must return a ``str`` with one of the values mentioned above.

0 commit comments

Comments
 (0)