pytest-dev / pytest-asyncio

Asyncio support for pytest
https://pytest-asyncio.readthedocs.io
Apache License 2.0
1.43k stars 152 forks source link

Clarify docs about requesting the `event_loop` fixture #964

Open tuukkamustonen opened 1 month ago

tuukkamustonen commented 1 month ago

https://pytest-asyncio.readthedocs.io/en/latest/reference/fixtures/index.html#event-loop suggests that it's fine to grab event_loop fixture in a non-async function.

0.21+ migration guide in https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/migrate_from_0_21.html suggests to convert all sync functions requesting the event_loop fixture into async functions, and then acquire the loop via asyncio.get_running_loop().

Which one is it, and what is the rationale of not depending on the event_loop fixture directly?

seifertm commented 1 month ago

The use of _eventloop is deprecated. We should adjust the docs to reflect that. The rationale is summarized here: https://github.com/pytest-dev/pytest-asyncio/issues/706#issuecomment-2282780197