MCPcopy
hub / github.com/psycopg/psycopg / test_rowlen_mismatch

Function test_rowlen_mismatch

tests/test_copy.py:136–147  ·  view source on GitHub ↗
(conn, format, use_set_types)

Source from the content-addressed store, hash-verified

134@pytest.mark.parametrize("format", pq.Format)
135@pytest.mark.parametrize("use_set_types", [True, False])
136def test_rowlen_mismatch(conn, format, use_set_types):
137 samples = [["foo", "bar"], ["foo", "bar", "baz"]]
138 cur = conn.cursor()
139 ensure_table(cur, "id serial primary key, data text, data2 text")
140 with pytest.raises(psycopg.DataError):
141 with cur.copy(
142 f"copy copy_in (data, data2) from stdin (format {format.name})"
143 ) as copy:
144 if use_set_types:
145 copy.set_types(["text", "text"])
146 for row in samples:
147 copy.write_row(row)
148
149
150def test_set_custom_type(conn, hstore):

Callers

nothing calls this directly

Calls 5

set_typesMethod · 0.80
ensure_tableFunction · 0.70
cursorMethod · 0.45
copyMethod · 0.45
write_rowMethod · 0.45

Tested by

no test coverage detected