From 57d6fda45ee21e29a3b2237cf7a5071ac37d9afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Fri, 14 Apr 2023 12:37:29 +0000 Subject: [PATCH] fix cluster test to run within delay context --- tests/test_asyncio/test_cwe_404.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/test_asyncio/test_cwe_404.py b/tests/test_asyncio/test_cwe_404.py index 9026f57994..474718595e 100644 --- a/tests/test_asyncio/test_cwe_404.py +++ b/tests/test_asyncio/test_cwe_404.py @@ -219,15 +219,18 @@ def set_delay(delay: int = 0): await r.set("foo", "foo") await r.set("bar", "bar") + async def op(r): + with set_delay(delay=delay): + return await r.get("foo") + all_clear() - with set_delay(delay=delay): - t = asyncio.create_task(r.get("foo")) - # One of the proxies will handle our request, wait for it to send - await any_wait() - await asyncio.sleep(delay) - t.cancel() - with pytest.raises(asyncio.CancelledError): - await t + t = asyncio.create_task(op(r)) + # One of the proxies will handle our request, wait for it to send + await any_wait() + await asyncio.sleep(delay) + t.cancel() + with pytest.raises(asyncio.CancelledError): + await t # try a number of requests to excercise all the connections async def doit():