-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce event_loop_policy fixture #662
Introduce event_loop_policy fixture #662
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #662 +/- ##
==========================================
+ Coverage 94.08% 94.31% +0.22%
==========================================
Files 2 2
Lines 406 422 +16
Branches 87 89 +2
==========================================
+ Hits 382 398 +16
Misses 14 14
Partials 10 10
☔ View full report in Codecov by Sentry. |
a327200
to
683ce86
Compare
Since I'm active on DPO, I just wanted to make sure you're aware of tentative plans to deprecate event loop policies in general (https://discuss.python.org/t/removing-the-asyncio-policy-system-asyncio-set-event-loop-policy-in-python-3-15/37553). From what I can tell, nothing has been decided yet, just bringing this to your attention. Although I think the idea here is sound. If event loop policies are deprecated, we could allow users to override a different fixture ( |
Thanks for mentioning the policy deprecation! The topic was also touched in #657 (comment) ff. If you also think the approach is generally sound, I'll continue to pursue this. |
c064c33
to
48cad08
Compare
9eef86b
to
c93fdd8
Compare
Signed-off-by: Michael Seifert <[email protected]>
Signed-off-by: Michael Seifert <[email protected]>
c93fdd8
to
9c2b996
Compare
This PR introduces the new fixture event_loop_policy. The fixture returns an instance of an asyncio.AbstractEventLoopPolicy. By default, the fixture has session (i.e. it is accessible by all tests) and returns the value of asyncio.get_event_loop_policy().
Users can run pytest-asyncio tests with different types of event loops by redefining the fixture to return a different event loop policy. Parametrizing the fixture causes pytest-asyncio tests to be run once for each specified policy. This allows writing tests against multiple different types of event loops.
Although the concept of event loop policies is likely going to be deprecated in CPython 3.13, it was decided that this functionality is still going to land in pytest-asyncio. Starting with CPython 3.13, pytest-asyncio will provide a migration path for the deprecated policy system.
Resolves #591
Prerequisite for #657