Skip to content

Commit ed43040

Browse files
[PR #8309/c29945a1 backport][3.9] Improve reliability of run_app test (#8315)
**This is a backport of PR #8309 as merged into master (c29945a).** Co-authored-by: Sam Bull <[email protected]>
1 parent ec2be05 commit ed43040

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_run_app.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,16 @@ async def stop(self, request: web.Request) -> web.Response:
916916

917917
def run_app(self, port: int, timeout: int, task, extra_test=None) -> asyncio.Task:
918918
async def test() -> None:
919-
await asyncio.sleep(1)
919+
await asyncio.sleep(0.5)
920920
async with ClientSession() as sess:
921-
async with sess.get(f"http://localhost:{port}/"):
922-
pass
921+
for _ in range(5): # pragma: no cover
922+
try:
923+
async with sess.get(f"http://localhost:{port}/"):
924+
pass
925+
except ClientConnectorError:
926+
await asyncio.sleep(0.5)
927+
else:
928+
break
923929
async with sess.get(f"http://localhost:{port}/stop"):
924930
pass
925931

0 commit comments

Comments
 (0)