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
That makes sense. The policy system is also deprecated as of Python 3.14.
pytest-asyncio doesn't really have a replacement yet. We want to keep the possibility to test with different loops, but didn't really find a suitable API for this so far. There's a draft PR that introduces a loop_factory argument to the asyncio marker, but it has some limitations.
The text and the example in that documentation also doesn't match. I for one would appreciate it if that documentation could be improved in the meantime
+1 on ivanthewebber's note about the text/example mismatch. As a downstream user adopting pytest-asyncio for new projects, the current snippet is misleading on two fronts:
uvloop.EventLoopPolicy() is deprecated since uvloop 0.21 (per Fix build for Python 3.14 MagicStack/uvloop#638) - calling it in the fixture emits a DeprecationWarning even before the test runs.
Python 3.14 deprecates the policy system entirely per seifertm's note above, so any interim doc that still hangs off event_loop_policy will age fast.
Two minimal interim options for the docs page (not blocking the long-term #1164 work):
a) Replace the snippet with the asyncio.Runner(loop_factory=uvloop.new_event_loop) pattern (works today, sidesteps deprecation, but requires the user to wire it through pytest-asyncio).
b) Keep the existing snippet but add a one-line callout noting both deprecations and pointing at #1164 for the future API direction.
Happy to PR option (b) - one-paragraph callout, no API contract change - if maintainers prefer that as a holding pattern.
#1373 improves the documentation by mentioning the deprecation of the policy system and providing a non-deprecated approach in the how-to. I'd say this issue is sufficiently addressed.
Activity
seifertm commentedon Jan 28, 2026
That makes sense. The policy system is also deprecated as of Python 3.14.
pytest-asyncio doesn't really have a replacement yet. We want to keep the possibility to test with different loops, but didn't really find a suitable API for this so far. There's a draft PR that introduces a loop_factory argument to the asyncio marker, but it has some limitations.
tjkuson commentedon Jan 28, 2026
I assume you meant to link to #1164?
Thanks for explaining, I'll read the thread and see if I have ideas when I next have some free time...
[-]Documented `uvloop` pattern is depcreated[/-][+]Documented `uvloop` pattern is deprecated[/+]Docs: update uvloop how-to to avoid deprecated EventLoopPolicy
ivanthewebber commentedon Mar 9, 2026
The text and the example in that documentation also doesn't match. I for one would appreciate it if that documentation could be improved in the meantime
golikovichev commentedon May 21, 2026
+1 on ivanthewebber's note about the text/example mismatch. As a downstream user adopting pytest-asyncio for new projects, the current snippet is misleading on two fronts:
uvloop.EventLoopPolicy()is deprecated since uvloop 0.21 (per Fix build for Python 3.14 MagicStack/uvloop#638) - calling it in the fixture emits aDeprecationWarningeven before the test runs.event_loop_policywill age fast.Two minimal interim options for the docs page (not blocking the long-term #1164 work):
a) Replace the snippet with the
asyncio.Runner(loop_factory=uvloop.new_event_loop)pattern (works today, sidesteps deprecation, but requires the user to wire it through pytest-asyncio).b) Keep the existing snippet but add a one-line callout noting both deprecations and pointing at #1164 for the future API direction.
Happy to PR option (b) - one-paragraph callout, no API contract change - if maintainers prefer that as a holding pattern.
tjkuson commentedon May 21, 2026
For what it's worth, this should be resolved once 1.4.0 is released (pre-releases are available if you'd like to try it out early).
golikovichev commentedon May 21, 2026
Thanks for the heads-up. Will try v1.4.0a2 to confirm the new pattern. Dropping the interim docs callout offer since the structural fix is on its way.
seifertm commentedon May 26, 2026
#1373 improves the documentation by mentioning the deprecation of the policy system and providing a non-deprecated approach in the how-to. I'd say this issue is sufficiently addressed.