MCPcopy
hub / github.com/psycopg/psycopg / test_file_writer

Function test_file_writer

tests/test_copy.py:603–614  ·  view source on GitHub ↗
(conn, format, buffer)

Source from the content-addressed store, hash-verified

601 [(pq.Format.TEXT, "sample_text"), (pq.Format.BINARY, "sample_binary")],
602)
603def test_file_writer(conn, format, buffer):
604 file = BytesIO()
605 conn.execute("set client_encoding to utf8")
606 cur = conn.cursor()
607 with Copy(cur, binary=format, writer=FileWriter(file)) as copy:
608 for record in sample_records:
609 copy.write_row(record)
610
611 file.seek(0)
612 want = globals()[buffer]
613 got = file.read()
614 assert got == want
615
616
617@pytest.mark.slow

Callers

nothing calls this directly

Calls 6

CopyClass · 0.90
FileWriterClass · 0.85
executeMethod · 0.45
cursorMethod · 0.45
write_rowMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected