From: Daniele Varrazzo Date: Sat, 6 Mar 2021 02:08:33 +0000 (+0100) Subject: Use gather instead of wait in tests to be coro friendly X-Git-Tag: 3.0.dev0~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7585ec0dc6b955f2e2b5a2084936f4ab69532cba;p=thirdparty%2Fpsycopg.git Use gather instead of wait in tests to be coro friendly --- diff --git a/tests/test_concurrency_async.py b/tests/test_concurrency_async.py index 446db1fb9..a75e09f71 100644 --- a/tests/test_concurrency_async.py +++ b/tests/test_concurrency_async.py @@ -35,7 +35,7 @@ async def test_commit_concurrency(aconn): # Stop the committer thread stop = True - await asyncio.wait([committer(), runner()]) + await asyncio.gather(committer(), runner()) assert notices.empty(), "%d notices raised" % notices.qsize() @@ -50,7 +50,7 @@ async def test_concurrent_execution(dsn): workers = [worker(), worker()] t0 = time.time() - await asyncio.wait(workers) + await asyncio.gather(*workers) assert time.time() - t0 < 0.8, "something broken in concurrency" @@ -75,12 +75,12 @@ async def test_notifies(aconn, dsn): async for n in gen: ns.append((n, time.time())) if len(ns) >= 2: - gen.close() + await gen.aclose() ns = [] t0 = time.time() workers = [notifier(), receiver()] - await asyncio.wait(workers) + await asyncio.gather(*workers) assert len(ns) == 2 n, t1 = ns[0] @@ -116,7 +116,7 @@ async def test_cancel(aconn): workers = [worker(), canceller()] t0 = time.time() - await asyncio.wait(workers) + await asyncio.gather(*workers) t1 = time.time() assert not errors diff --git a/tests/test_connection_async.py b/tests/test_connection_async.py index 956cff151..a25d2d732 100644 --- a/tests/test_connection_async.py +++ b/tests/test_connection_async.py @@ -59,7 +59,7 @@ async def test_connect_timeout(): elapsed = time.time() - t0 elapsed = 0 - await asyncio.wait([closer(), connect()]) + await asyncio.gather(closer(), connect()) assert elapsed == pytest.approx(1.0, abs=0.05)