Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

event_loop_policy for single test #1101

Copy link
Copy link
Open
Copy link
@Dreamsorcerer

Description

@Dreamsorcerer
Issue body actions

It would be good if there was an easy way to change the event_loop_policy for a single test. I can't see any way to do this currently from the documentation (other than moving a single test to it's own module).

In aiohttp, we currently have these fixtures in conftest.py, which I'm looking to remove:

@pytest.fixture
def selector_loop() -> Iterator[asyncio.AbstractEventLoop]:
    policy = asyncio.WindowsSelectorEventLoopPolicy()  # type: ignore[attr-defined]
    asyncio.set_event_loop_policy(policy)

    with loop_context(policy.new_event_loop) as:
        asyncio.set_event_loop(_loop)
        yield _loop


@pytest.fixture
def uvloop_loop() -> Iterator[asyncio.AbstractEventLoop]:
    policy = uvloop.EventLoopPolicy()
    asyncio.set_event_loop_policy(policy)

    with loop_context(policy.new_event_loop) as:
        asyncio.set_event_loop(_loop)
        yield _loop

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.