(conn, format)
| 353 | |
| 354 | @pytest.mark.parametrize("format", pq.Format) |
| 355 | def test_subclass_nulling_dumper(conn, format): |
| 356 | Base: type = StrNoneDumper if format == pq.Format.TEXT else StrNoneBinaryDumper |
| 357 | |
| 358 | class MyStrDumper(Base): # type: ignore |
| 359 | |
| 360 | def dump(self, obj): |
| 361 | return super().dump(obj) if obj else None |
| 362 | |
| 363 | conn.adapters.register_dumper(str, MyStrDumper) |
| 364 | |
| 365 | cur = conn.cursor() |
| 366 | ensure_table(cur, sample_tabledef) |
| 367 | |
| 368 | with cur.copy(f"copy copy_in (data) from stdin (format {format.name})") as copy: |
| 369 | copy.write_row(("hello",)) |
| 370 | copy.write_row(("",)) |
| 371 | |
| 372 | cur.execute("select data from copy_in order by col1") |
| 373 | recs = cur.fetchall() |
| 374 | assert recs == [("hello",), (None,)] |
| 375 | |
| 376 | |
| 377 | @pytest.mark.parametrize("format", pq.Format) |
nothing calls this directly
no test coverage detected