Skip to content

Commit a9debda

Browse files
committed
Fix tests with psycopg < 3.1.0
1 parent f80f367 commit a9debda

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/instrumentation/psycopg_tests.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
has_postgres_configured = "POSTGRES_DB" in os.environ
4949

50+
PSYCOPG_VERSION = tuple([int(x) for x in psycopg.version.__version__.split() if x.isdigit()])
51+
5052

5153
def connect_kwargs():
5254
return {
@@ -86,10 +88,14 @@ def test_cursor_execute_signature(instrument, postgres_connection, elasticapm_cl
8688
@pytest.mark.skipif(not has_postgres_configured, reason="PostgresSQL not configured")
8789
def test_cursor_executemany_signature(instrument, postgres_connection, elasticapm_client):
8890
cursor = postgres_connection.cursor()
91+
if PSYCOPG_VERSION < (3, 1, 0):
92+
kwargs = {}
93+
else:
94+
kwargs = {"returning": False}
8995
res = cursor.executemany(
9096
query="INSERT INTO test VALUES (%s, %s)",
9197
params_seq=((4, "four"),),
92-
returning=False,
98+
**kwargs,
9399
)
94100
assert res is None
95101

0 commit comments

Comments
 (0)