Skip to content

Commit c29945a

Browse files
Improve reliability of run_app test (#8309)
1 parent 7afb8d9 commit c29945a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_run_app.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,10 +931,16 @@ async def stop(self, request: web.Request) -> web.Response:
931931

932932
def run_app(self, port: int, timeout: int, task, extra_test=None) -> asyncio.Task:
933933
async def test() -> None:
934-
await asyncio.sleep(1)
934+
await asyncio.sleep(0.5)
935935
async with ClientSession() as sess:
936-
async with sess.get(f"http://localhost:{port}/"):
937-
pass
936+
for _ in range(5): # pragma: no cover
937+
try:
938+
async with sess.get(f"http://localhost:{port}/"):
939+
pass
940+
except ClientConnectorError:
941+
await asyncio.sleep(0.5)
942+
else:
943+
break
938944
async with sess.get(f"http://localhost:{port}/stop"):
939945
pass
940946

0 commit comments

Comments
 (0)