From: Denis Laxalde Date: Fri, 5 Nov 2021 12:21:23 +0000 (+0100) Subject: Declare 'elapsed' value before usage in async connection tests X-Git-Tag: 3.0.3~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a76bb842aa4f7ae131174093288da2cbd9031370;p=thirdparty%2Fpsycopg.git Declare 'elapsed' value before usage in async connection tests Resolves mypy error: error: No binding for nonlocal "elapsed" found [misc] --- diff --git a/tests/test_connection_async.py b/tests/test_connection_async.py index 7f115ca34..67c297a19 100644 --- a/tests/test_connection_async.py +++ b/tests/test_connection_async.py @@ -52,6 +52,8 @@ async def test_connect_timeout(): await asyncio.sleep(1.5) s.close() + elapsed: float = 0 + async def connect(): t0 = time.time() with pytest.raises(psycopg.OperationalError, match="timeout expired"): @@ -61,7 +63,6 @@ async def test_connect_timeout(): nonlocal elapsed elapsed = time.time() - t0 - elapsed = 0 await asyncio.gather(closer(), connect()) assert elapsed == pytest.approx(1.0, abs=0.05)