From: Daniele Varrazzo Date: Mon, 22 Nov 2021 01:44:49 +0000 (+0100) Subject: Guard delay_connection in tests for negative sleep argument X-Git-Tag: 3.0.5~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=095ed4bec7148a92c1e0e55175fba2d91668fb76;p=thirdparty%2Fpsycopg.git Guard delay_connection in tests for negative sleep argument It happens if connection time was slow enough. --- diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 177044dec..8616c3bb0 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -1080,7 +1080,7 @@ def delay_connection(monkeypatch, sec): t0 = time() rv = connect_orig(*args, **kwargs) t1 = time() - sleep(sec - (t1 - t0)) + sleep(max(0, sec - (t1 - t0))) return rv connect_orig = psycopg.Connection.connect diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index d7d2fdca4..38db5733f 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -1055,7 +1055,7 @@ def delay_connection(monkeypatch, sec): t0 = time() rv = await connect_orig(*args, **kwargs) t1 = time() - await asyncio.sleep(sec - (t1 - t0)) + await asyncio.sleep(max(0, sec - (t1 - t0))) return rv connect_orig = psycopg.AsyncConnection.connect