Skip to content

Commit

Permalink
docs: Clarify deprecation of event_loop fixture.
Browse files Browse the repository at this point in the history
  • Loading branch information
seifertm committed Dec 31, 2024
1 parent a4e82ab commit 2fd10f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/reference/fixtures/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Fixtures

event_loop
==========
*This fixture is deprecated.*

*If you want to request an asyncio event loop with a scope other than function
scope, use the "loop_scope" argument to* :ref:`reference/markers/asyncio` *when marking the tests.
If you want to return different types of event loops, use the* :ref:`reference/fixtures/event_loop_policy`
*fixture.*

Creates a new asyncio event loop based on the current event loop policy. The new loop
is available as the return value of this fixture for synchronous functions, or via `asyncio.get_running_loop <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop>`__ for asynchronous functions.
The event loop is closed when the fixture scope ends.
Expand All @@ -20,6 +27,8 @@ If you need to change the type of the event loop, prefer setting a custom event
If the ``pytest.mark.asyncio`` decorator is applied to a test function, the ``event_loop``
fixture will be requested automatically by the test function.

.. _reference/fixtures/event_loop_policy:

event_loop_policy
=================
Returns the event loop policy used to create asyncio event loops.
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/markers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Markers
=======

.. _reference/markers/asyncio:

``pytest.mark.asyncio``
=======================
A coroutine or async generator with this marker is treated as a test function by pytest.
Expand Down

0 comments on commit 2fd10f8

Please sign in to comment.