Skip to content

Modernize event loop handling in aiohttp tests #455

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

musicinmybrain
Copy link
Contributor

Issue #, if available:

N/A

Description of changes:

This fixes compatibility with pytest-aiohttp 1.1.0.

First, migrate aiohttp tests from loop fixture to event_loop. This follows advice from an upstream deprecation warning, and furthermore, as of pytest-aiohttp 1.1.0 these tests break since the loop fixture is no longer available at all.

Then, in async tests, replace event_loop fixtures with calls to asyncio.get_running_loop(), as advised by, e.g.:

tests/ext/aiohttp/test_middleware.py:123
  tests/ext/aiohttp/test_middleware.py:123: PytestDeprecationWarning: test_ok is asynchronous and expl
icitly requests the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio
.get_running_loop()" instead.
    async def test_ok(aiohttp_client, event_loop, recorder):

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@musicinmybrain musicinmybrain requested a review from a team as a code owner April 16, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant