]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added test to verify can't execute(copy)
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 20 Nov 2020 02:59:22 +0000 (02:59 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 20 Nov 2020 03:01:08 +0000 (03:01 +0000)
tests/test_cursor.py
tests/test_cursor_async.py

index 5dc132eddece68dabd826662aa0606ad31c0628a..7b3adfedccc849e1981def5c07c6621a0192f27c 100644 (file)
@@ -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])
index 79ca61b7be27db2ba01f8a57371b0a961bdf5b84..7ec01a67ec787d0f8d8755dad1d53667e3e80f2b 100644 (file)
@@ -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])