(conn, format)
| 324 | |
| 325 | @pytest.mark.parametrize("format", pq.Format) |
| 326 | def test_subclass_adapter(conn, format): |
| 327 | if format == pq.Format.TEXT: |
| 328 | from psycopg.types.string import StrDumper as BaseDumper |
| 329 | else: |
| 330 | from psycopg.types.string import StrBinaryDumper |
| 331 | |
| 332 | BaseDumper = StrBinaryDumper # type: ignore |
| 333 | |
| 334 | class MyStrDumper(BaseDumper): |
| 335 | |
| 336 | def dump(self, obj): |
| 337 | rv = super().dump(obj) |
| 338 | assert rv |
| 339 | return bytes(rv) * 2 |
| 340 | |
| 341 | conn.adapters.register_dumper(str, MyStrDumper) |
| 342 | |
| 343 | cur = conn.cursor() |
| 344 | ensure_table(cur, sample_tabledef) |
| 345 | |
| 346 | with cur.copy(f"copy copy_in (data) from stdin (format {format.name})") as copy: |
| 347 | copy.write_row(("hello",)) |
| 348 | |
| 349 | cur.execute("select data from copy_in") |
| 350 | rec = cur.fetchone() |
| 351 | assert rec[0] == "hellohello" |
| 352 | |
| 353 | |
| 354 | @pytest.mark.parametrize("format", pq.Format) |
nothing calls this directly
no test coverage detected
searching dependent graphs…