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
Clarify documentation of event_loop fixture (#375)
* docs: Removed contradicting information about the event_loop fixture not setting the global event loop.
Signed-off-by: Michael Seifert <[email protected]>
* docs: Clarified the effect of pytest.mark.asyncio with regards to the event_loop fixture.
Signed-off-by: Michael Seifert <[email protected]>
* docs: Provide an example for redefining the event_loop fixture rather than for setting a custom event loop.
Signed-off-by: Michael Seifert <[email protected]>
Copy file name to clipboardExpand all lines: README.rst
+14-16
Original file line number
Diff line number
Diff line change
@@ -123,42 +123,40 @@ Fixtures
123
123
124
124
``event_loop``
125
125
~~~~~~~~~~~~~~
126
-
Creates and injects a new instance of the default asyncio event loop. By
127
-
default, the loop will be closed at the end of the test (i.e. the default
128
-
fixture scope is ``function``).
126
+
Creates a new asyncio event loop based on the current event loop policy. The new loop
127
+
is available as the return value of this fixture or via `asyncio.get_running_loop <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop>`__.
128
+
The event loop is closed when the fixture scope ends. The fixture scope defaults
129
+
to ``function`` scope.
129
130
130
131
Note that just using the ``event_loop`` fixture won't make your test function
131
132
a coroutine. You'll need to interact with the event loop directly, using methods
132
133
like ``event_loop.run_until_complete``. See the ``pytest.mark.asyncio`` marker
133
134
for treating test functions like coroutines.
134
135
135
-
Simply using this fixture will not set the generated event loop as the
136
-
default asyncio event loop, or change the asyncio event loop policy in any way.
0 commit comments