From b4486c39a1d65b56a1be20f792cee2e07b858fc1 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 28 Mar 2022 20:03:55 +0200 Subject: [PATCH] test: add xfailing test for rowcount in pipelined executemany --- tests/test_pipeline.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 090fb11f1..49a1bca17 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -168,18 +168,31 @@ def test_executemany(conn): "insert into execmanypipeline(num) values (%s) returning id", [(10,), (20,)], ) - - # TODO: this is a bug, it should be 2. It is caused by reentering the - # pipeline mode in executemany(). Leaving it here to monitor how it - # changes. The snag is in Cursor._set_results_from_pipeline() - assert cur.rowcount == 0 - assert cur.fetchone() == (1,) assert cur.nextset() assert cur.fetchone() == (2,) assert cur.nextset() is None +@pytest.mark.xfail +def test_executemany_rowcount(conn): + conn.autocommit = True + conn.execute( + "create temp table test_executemany_rowcount (" + " id serial primary key, num integer)" + ) + with conn.pipeline(), conn.cursor() as cur: + cur.executemany( + "insert into test_executemany_rowcount (num) values (%s) returning id", + [(10,), (20,)], + ) + + # TODO: this is a bug. It is caused by reentering the pipeline mode in + # executemany(). Leaving it here to monitor how it changes. The snag is + # in Cursor._set_results_from_pipeline() + assert cur.rowcount == 2 + + def test_prepared(conn): conn.autocommit = True with conn.pipeline(): -- 2.47.2