Skip to content
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

Support setting the loop_factory in IsolatedAsyncioTestCase #110774

Closed
graingert opened this issue Oct 12, 2023 · 0 comments
Closed

Support setting the loop_factory in IsolatedAsyncioTestCase #110774

graingert opened this issue Oct 12, 2023 · 0 comments
Labels
topic-asyncio type-feature A feature request or enhancement

Comments

@graingert
Copy link
Contributor

graingert commented Oct 12, 2023

Proposal:

I want to be able to create utility subclasses of IsolatedAsyncioTestCase that use either uvloop or a specific event loop using the asyncio.Runner(..., loop_factory=...) kwarg, Ideally it would look something like:

Another advantage of setting loop_factory would allow use of IsolatedAsyncioTestCase without using def tearDownModule(): asyncio.set_event_loop_policy(None) because asyncio.Runner does not call asyncio.get_event_loop_policy() when called with a loop_factory

class DefaultIsolatedAsyncioTestCase:
    """
    Use the most efficient event loop regardless of what has been configured with asyncio.set_event_loop_policy
    does not require `def tearDownModule(): asyncio.set_event_loop_policy(None)`
    """
    loop_factory = asyncio.EventLoop

or

class UvloopIsolatedAsyncioTestCase:
    """
    runs tests on uvloop
    """
    loop_factory = uvloop.new_event_loop

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/support-setting-the-loop-factory-in-isolatedasynciotestcase/36027

Linked PRs

@graingert graingert added the type-feature A feature request or enhancement label Oct 12, 2023
gvanrossum pushed a commit that referenced this issue Oct 31, 2023
…yncioTestCase (#110776)


Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
FullteaR pushed a commit to FullteaR/cpython that referenced this issue Nov 3, 2023
…atedAsyncioTestCase (python#110776)


Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…atedAsyncioTestCase (python#110776)


Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-asyncio type-feature A feature request or enhancement
Projects
Status: Done
Development

No branches or pull requests

3 participants