From ed43040613988fc4666109aca82a5180ff165df5 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:13:07 +0100 Subject: [PATCH] [PR #8309/c29945a1 backport][3.9] Improve reliability of run_app test (#8315) **This is a backport of PR #8309 as merged into master (c29945a19ef93ac05f7499bfc410e234270ddbb3).** Co-authored-by: Sam Bull --- tests/test_run_app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_run_app.py b/tests/test_run_app.py index 1166421a4eb..5696928b219 100644 --- a/tests/test_run_app.py +++ b/tests/test_run_app.py @@ -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