Skip to content

Commit fe94cef

Browse files
committed
docs: Added how-to guide on changing the default event loop scope of all fixtures.
Signed-off-by: Michael Seifert <[email protected]>
1 parent d90ad95 commit fe94cef

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
==========================================================
2+
How to change the default event loop scope of all fixtures
3+
==========================================================
4+
The :ref:`configuration/asyncio_default_fixture_loop_scope` configuration option sets the default event loop scope for asynchronous fixtures. The following code snippets configure all fixtures to run in a session-scoped loop by default:
5+
6+
.. code-block:: ini
7+
:caption: pytest.ini
8+
9+
[pytest]
10+
asyncio_default_fixture_loop_scope = session
11+
12+
.. code-block:: toml
13+
:caption: pyproject.toml
14+
15+
[tool.pytest.ini_options]
16+
asyncio_default_fixture_loop_scope = "session"
17+
18+
.. code-block:: ini
19+
:caption: setup.cfg
20+
21+
[tool:pytest]
22+
asyncio_default_fixture_loop_scope = session
23+
24+
Please refer to :ref:`configuration/asyncio_default_fixture_loop_scope` for other valid scopes.

docs/source/how-to-guides/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ How-To Guides
66
:hidden:
77

88
change_fixture_loop
9+
change_default_fixture_loop
910
run_class_tests_in_same_loop
1011
run_module_tests_in_same_loop
1112
run_package_tests_in_same_loop

docs/source/reference/configuration.rst

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Configuration
33
=============
44

5+
.. _configuration/asyncio_default_fixture_loop_scope:
6+
57
asyncio_default_fixture_loop_scope
68
==================================
79
Determines the default event loop scope of asynchronous fixtures. When this configuration option is unset, it defaults to the fixture scope. In future versions of pytest-asyncio, the value will default to ``function`` when unset. Possible values are: ``function``, ``class``, ``module``, ``package``, ``session``

0 commit comments

Comments
 (0)