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

work around the changes in 3.11, eg asyncio.TimeoutError is an OSError, and IsolatedAsyncioTestCase calls set_event_loop differently #6877

Merged
merged 7 commits into from
Aug 22, 2022
14 changes: 5 additions & 9 deletions aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,9 @@ def get_app(self) -> Application:
"""
raise RuntimeError("Did you forget to define get_application()?")

def setUp(self) -> None:
try:
self.loop = asyncio.get_running_loop()
except RuntimeError:
self.loop = asyncio.get_event_loop_policy().get_event_loop()
Comment on lines -435 to -436
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit needed to be recovered in aiohttp v3.8 to preserve the compatibility with Python 3.6: ef6a373.


self.loop.run_until_complete(self.setUpAsync())
async def asyncSetUp(self):
graingert marked this conversation as resolved.
Show resolved Hide resolved
self.loop = asyncio.get_running_loop()
return await self.setUpAsync()

async def setUpAsync(self) -> None:
self.app = await self.get_application()
Expand All @@ -444,8 +440,8 @@ async def setUpAsync(self) -> None:

await self.client.start_server()

def tearDown(self) -> None:
self.loop.run_until_complete(self.tearDownAsync())
async def asyncTearDown(self) -> None:
return await self.tearDownAsync()

async def tearDownAsync(self) -> None:
await self.client.close()
Expand Down