| 1 |
======================================================= |
| 2 |
How to change the default event loop scope of all tests |
| 3 |
======================================================= |
| 4 |
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 |
.. tabs:: |
| 7 |
|
| 8 |
.. tab:: pytest.ini |
| 9 |
|
| 10 |
.. code-block:: ini |
| 11 |
|
| 12 |
[pytest] |
| 13 |
asyncio_default_test_loop_scope = session |
| 14 |
|
| 15 |
.. tab:: pyproject.toml |
| 16 |
|
| 17 |
.. code-block:: toml |
| 18 |
|
| 19 |
[tool.pytest.ini_options] |
| 20 |
asyncio_default_test_loop_scope = "session" |
| 21 |
|
| 22 |
.. tab:: setup.cfg |
| 23 |
|
| 24 |
.. code-block:: ini |
| 25 |
|
| 26 |
[tool:pytest] |
| 27 |
asyncio_default_test_loop_scope = session |
| 28 |
|
| 29 |
Please refer to :ref:`configuration/asyncio_default_test_loop_scope` |
| 30 |
for other valid scopes. |