From e2f1fdb908a878ddeac50583f10622cba57afbdc Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 20 Nov 2020 02:59:22 +0000 Subject: [PATCH] Added test to verify can't execute(copy) --- tests/test_cursor.py | 10 ++++++++++ tests/test_cursor_async.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 5dc132edd..7b3adfedc 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -84,6 +84,16 @@ def test_execute_empty_query(conn, query): cur.fetchone() +@pytest.mark.parametrize( + "query", ["copy testcopy from stdin", "copy testcopy to stdout"] +) +def test_execute_copy(conn, query): + cur = conn.cursor() + cur.execute("create table testcopy (id int)") + with pytest.raises(psycopg3.ProgrammingError): + cur.execute(query) + + def test_fetchone(conn): cur = conn.cursor() cur.execute("select %s::int, %s::text, %s::text", [1, "foo", None]) diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index 79ca61b7b..7ec01a67e 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -89,6 +89,16 @@ async def test_execute_empty_query(aconn, query): await cur.fetchone() +@pytest.mark.parametrize( + "query", ["copy testcopy from stdin", "copy testcopy to stdout"] +) +async def test_execute_copy(aconn, query): + cur = await aconn.cursor() + await cur.execute("create table testcopy (id int)") + with pytest.raises(psycopg3.ProgrammingError): + await cur.execute(query) + + async def test_fetchone(aconn): cur = await aconn.cursor() await cur.execute("select %s::int, %s::text, %s::text", [1, "foo", None]) -- 2.47.3