Skip to content

Commit

Permalink
[PR #8309/c29945a1 backport][3.9] Improve reliability of run_app test (
Browse files Browse the repository at this point in the history
…#8315)

**This is a backport of PR #8309 as merged into master
(c29945a).**

Co-authored-by: Sam Bull <git@sambull.org>
  • Loading branch information
patchback[bot] and Dreamsorcerer authored Apr 8, 2024
1 parent ec2be05 commit ed43040
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/test_run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,16 @@ async def stop(self, request: web.Request) -> web.Response:

def run_app(self, port: int, timeout: int, task, extra_test=None) -> asyncio.Task:
async def test() -> None:
await asyncio.sleep(1)
await asyncio.sleep(0.5)
async with ClientSession() as sess:
async with sess.get(f"http://localhost:{port}/"):
pass
for _ in range(5): # pragma: no cover
try:
async with sess.get(f"http://localhost:{port}/"):
pass
except ClientConnectorError:
await asyncio.sleep(0.5)
else:
break
async with sess.get(f"http://localhost:{port}/stop"):
pass

Expand Down

0 comments on commit ed43040

Please sign in to comment.