From: Denis Laxalde Date: Tue, 2 Nov 2021 12:14:12 +0000 (+0100) Subject: Use setattr() when monkeypatching in pool tests X-Git-Tag: 3.0.2~2^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4dd92ab9e680396af574711c0b6571abf6d5042f;p=thirdparty%2Fpsycopg.git Use setattr() when monkeypatching in pool tests This is to avoid mypy error: Cannot assign to a method. --- diff --git a/tests/pool/test_sched.py b/tests/pool/test_sched.py index d35332fec..a3bdd5cfa 100644 --- a/tests/pool/test_sched.py +++ b/tests/pool/test_sched.py @@ -111,7 +111,7 @@ def test_empty_queue_timeout(): times.append(time() - t0) return rv - s._event.wait = wait_logging + setattr(s._event, "wait", wait_logging) s.EMPTY_QUEUE_TIMEOUT = 0.2 t = Thread(target=s.run) @@ -138,7 +138,7 @@ def test_first_task_rescheduling(): times.append(time() - t0) return rv - s._event.wait = wait_logging + setattr(s._event, "wait", wait_logging) s.EMPTY_QUEUE_TIMEOUT = 0.1 s.enter(0.4, lambda: None) diff --git a/tests/pool/test_sched_async.py b/tests/pool/test_sched_async.py index 2ea36dd1a..651e9038f 100644 --- a/tests/pool/test_sched_async.py +++ b/tests/pool/test_sched_async.py @@ -113,7 +113,7 @@ async def test_empty_queue_timeout(): times.append(time() - t0) return rv - s._event.wait = wait_logging + setattr(s._event, "wait", wait_logging) s.EMPTY_QUEUE_TIMEOUT = 0.2 t = create_task(s.run()) @@ -141,7 +141,7 @@ async def test_first_task_rescheduling(): times.append(time() - t0) return rv - s._event.wait = wait_logging + setattr(s._event, "wait", wait_logging) s.EMPTY_QUEUE_TIMEOUT = 0.1 async def noop():