From dc69f8b3d8be8d8e7f24649b8cf39525555e6c40 Mon Sep 17 00:00:00 2001 From: Christoph Thiede Date: Tue, 17 Aug 2021 23:19:24 +0200 Subject: [PATCH] Make db_test._perform_query compatible with Psycopg 2.9 Remove context handler for connection. Complements https://github.com/psycopg/psycopg2/issues/941. --- tests/_utils/db_test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/_utils/db_test.py b/tests/_utils/db_test.py index 3b84b1c9..20d83f55 100644 --- a/tests/_utils/db_test.py +++ b/tests/_utils/db_test.py @@ -55,10 +55,9 @@ def _perform_query(query): database='postgres' ) try: - with connection: - connection.autocommit = True # required for meta queries - with connection.cursor() as cursor: - return cursor.execute(query) + connection.autocommit = True # required for meta queries + with connection.cursor() as cursor: + return cursor.execute(query) finally: connection.close()