You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Configuration option for setting default loop_scope for tests
New configuration option, asyncio_default_test_loop_scope, provides
default value for loop_scope argument of asyncio marker. This can be
used to use the same event loop in auto mode without need to use
modifyitems hook.
Test functions can still override loop_scope by using asyncio marker.
The :ref:`configuration/asyncio_default_test_loop_scope` configuration option sets the default event loop scope for asynchronous tests. The following code snippets configure all tests to run in a session-scoped loop by default:
5
+
6
+
.. code-block:: ini
7
+
:caption: pytest.ini
8
+
9
+
[pytest]
10
+
asyncio_default_test_loop_scope = session
11
+
12
+
.. code-block:: toml
13
+
:caption: pyproject.toml
14
+
15
+
[tool.pytest.ini_options]
16
+
asyncio_default_test_loop_scope = "session"
17
+
18
+
.. code-block:: ini
19
+
:caption: setup.cfg
20
+
21
+
[tool:pytest]
22
+
asyncio_default_test_loop_scope = session
23
+
24
+
Please refer to :ref:`configuration/asyncio_default_test_loop_scope` for other valid scopes.
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``
Determines the default event loop scope of asynchronous tests. When this configuration option is unset, it default to function scope. Possible values are: ``function``, ``class``, ``module``, ``package``, ``session``
16
+
11
17
asyncio_mode
12
18
============
13
19
The pytest-asyncio mode can be set by the ``asyncio_mode`` configuration option in the `configuration file
0 commit comments