File: change_default_fixture_loop.rst

package info (click to toggle)
python-pytest-asyncio 0.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 656 kB
  • sloc: python: 3,108; makefile: 26; sh: 1
file content (24 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
==========================================================
How to change the default event loop scope of all fixtures
==========================================================
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:

.. code-block:: ini
    :caption: pytest.ini

    [pytest]
    asyncio_default_fixture_loop_scope = session

.. code-block:: toml
    :caption: pyproject.toml

    [tool.pytest.ini_options]
    asyncio_default_fixture_loop_scope = "session"

.. code-block:: ini
    :caption: setup.cfg

    [tool:pytest]
    asyncio_default_fixture_loop_scope = session

Please refer to :ref:`configuration/asyncio_default_fixture_loop_scope` for other valid scopes.