@@ -244,8 +244,8 @@ and `pytest-datafiles <https://pypi.org/project/pytest-datafiles/>`__.
244
244
245
245
.. _smtpshared :
246
246
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
+ --------------------------------------------------------------------
249
249
250
250
.. regendoc:wipe
251
251
@@ -356,29 +356,23 @@ instance, you can simply declare it:
356
356
# all tests needing it
357
357
...
358
358
359
- Finally, the ``class `` scope will invoke the fixture once per test *class *.
360
359
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
+ ^^^^^^^^^^^^^^
369
362
363
+ Fixtures are created when first requested by a test, and are destroyed based on their ``scope ``:
370
364
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.
371
370
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 ::
381
372
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.
382
376
383
377
.. _dynamic scope :
384
378
0 commit comments