]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor(copy): rename QueueWriter to QueuedLibpqWriter
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 23 Jul 2022 22:02:21 +0000 (23:02 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 26 Jul 2022 12:01:42 +0000 (13:01 +0100)
psycopg/psycopg/copy.py
tests/test_copy.py
tests/test_copy_async.py

index 04632c9496f7feec19c03ec7ea3a081637a39d47..f53c9a98a9b2826400c488729995e9ea831a034e 100644 (file)
@@ -347,7 +347,7 @@ class LibpqWriter(Writer):
         self.cursor._rowcount = nrows if nrows is not None else -1
 
 
-class QueueWriter(LibpqWriter):
+class QueuedLibpqDriver(LibpqWriter):
     """
     A writer using a buffer to queue data to write to a Postgres database.
 
@@ -542,7 +542,7 @@ class AsyncLibpqWriter(AsyncWriter):
         self.cursor._rowcount = nrows if nrows is not None else -1
 
 
-class AsyncQueueWriter(AsyncLibpqWriter):
+class AsyncQueuedLibpqWriter(AsyncLibpqWriter):
     """
     An `AsyncWriter` using a buffer to queue data to write.
 
index e6e3eb19990559c8796c45308d2d4df4978ff5e6..547089f3806bc2d6acce8d714e5a86c4e55f515a 100644 (file)
@@ -12,7 +12,7 @@ from psycopg import pq
 from psycopg import sql
 from psycopg import errors as e
 from psycopg.pq import Format
-from psycopg.copy import Copy, Writer, LibpqWriter, QueueWriter
+from psycopg.copy import Copy, Writer, LibpqWriter, QueuedLibpqDriver
 from psycopg.adapt import PyFormat
 from psycopg.types import TypeInfo
 from psycopg.types.hstore import register_hstore
@@ -618,7 +618,7 @@ def test_worker_life(conn, format, buffer):
     cur = conn.cursor()
     ensure_table(cur, sample_tabledef)
     with cur.copy(
-        f"copy copy_in from stdin (format {format.name})", writer=QueueWriter(cur)
+        f"copy copy_in from stdin (format {format.name})", writer=QueuedLibpqDriver(cur)
     ) as copy:
         assert not copy.writer._worker
         copy.write(globals()[buffer])
@@ -638,7 +638,7 @@ def test_worker_error_propagated(conn, monkeypatch):
     cur = conn.cursor()
     cur.execute("create temp table wat (a text, b text)")
     with pytest.raises(ZeroDivisionError):
-        with cur.copy("copy wat from stdin", writer=QueueWriter(cur)) as copy:
+        with cur.copy("copy wat from stdin", writer=QueuedLibpqDriver(cur)) as copy:
             copy.write("a,b")
 
 
index cd450e54760ee7f13d90d42b88e30a7b839906ff..e841d21c3aedaff67e3d34b042c41313301262f7 100644 (file)
@@ -12,7 +12,8 @@ from psycopg import pq
 from psycopg import sql
 from psycopg import errors as e
 from psycopg.pq import Format
-from psycopg.copy import AsyncCopy, AsyncWriter, AsyncLibpqWriter, AsyncQueueWriter
+from psycopg.copy import AsyncCopy
+from psycopg.copy import AsyncWriter, AsyncLibpqWriter, AsyncQueuedLibpqWriter
 from psycopg.types import TypeInfo
 from psycopg.adapt import PyFormat
 from psycopg.types.hstore import register_hstore
@@ -620,7 +621,8 @@ async def test_worker_life(aconn, format, buffer):
     cur = aconn.cursor()
     await ensure_table(cur, sample_tabledef)
     async with cur.copy(
-        f"copy copy_in from stdin (format {format.name})", writer=AsyncQueueWriter(cur)
+        f"copy copy_in from stdin (format {format.name})",
+        writer=AsyncQueuedLibpqWriter(cur),
     ) as copy:
         assert not copy.writer._worker
         await copy.write(globals()[buffer])
@@ -642,7 +644,7 @@ async def test_worker_error_propagated(aconn, monkeypatch):
     await cur.execute("create temp table wat (a text, b text)")
     with pytest.raises(ZeroDivisionError):
         async with cur.copy(
-            "copy wat from stdin", writer=AsyncQueueWriter(cur)
+            "copy wat from stdin", writer=AsyncQueuedLibpqWriter(cur)
         ) as copy:
             await copy.write("a,b")