()
| 539 | |
| 540 | @needs_cffi |
| 541 | def test_imported_batch_reader_error(): |
| 542 | c_stream = ffi.new("struct ArrowArrayStream*") |
| 543 | ptr_stream = int(ffi.cast("uintptr_t", c_stream)) |
| 544 | |
| 545 | schema = pa.schema([('foo', pa.int32())]) |
| 546 | batches = [pa.record_batch([[1, 2, 3]], schema=schema), |
| 547 | pa.record_batch([[4, 5, 6]], schema=schema)] |
| 548 | buf = make_serialized(schema, batches) |
| 549 | |
| 550 | # Open a corrupt/incomplete stream and export it |
| 551 | reader = pa.ipc.open_stream(buf[:-16]) |
| 552 | reader._export_to_c(ptr_stream) |
| 553 | del reader |
| 554 | |
| 555 | reader_new = pa.RecordBatchReader._import_from_c(ptr_stream) |
| 556 | batch = reader_new.read_next_batch() |
| 557 | assert batch == batches[0] |
| 558 | with pytest.raises(OSError, |
| 559 | match="Expected to be able to read 16 bytes " |
| 560 | "for message body, got 8"): |
| 561 | reader_new.read_next_batch() |
| 562 | |
| 563 | # Again, but call read_all() |
| 564 | reader = pa.ipc.open_stream(buf[:-16]) |
| 565 | reader._export_to_c(ptr_stream) |
| 566 | del reader |
| 567 | |
| 568 | reader_new = pa.RecordBatchReader._import_from_c(ptr_stream) |
| 569 | with pytest.raises(OSError, |
| 570 | match="Expected to be able to read 16 bytes " |
| 571 | "for message body, got 8"): |
| 572 | reader_new.read_all() |
| 573 | |
| 574 | |
| 575 | @pytest.mark.parametrize('obj', [pa.int32(), pa.field('foo', pa.int32()), |
nothing calls this directly
no test coverage detected