From: Daniele Varrazzo Date: Fri, 20 Nov 2020 02:59:22 +0000 (+0000) Subject: Added test to verify can't execute(copy) X-Git-Tag: 3.0.dev0~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2f1fdb908a878ddeac50583f10622cba57afbdc;p=thirdparty%2Fpsycopg.git Added test to verify can't execute(copy) --- 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])