()
| 1033 | |
| 1034 | |
| 1035 | def test_mock_output_stream(): |
| 1036 | # Make sure that the MockOutputStream and the BufferOutputStream record the |
| 1037 | # same size |
| 1038 | |
| 1039 | # 10 bytes |
| 1040 | val = b'dataabcdef' |
| 1041 | |
| 1042 | f1 = pa.MockOutputStream() |
| 1043 | f2 = pa.BufferOutputStream() |
| 1044 | |
| 1045 | K = 1000 |
| 1046 | for i in range(K): |
| 1047 | f1.write(val) |
| 1048 | f2.write(val) |
| 1049 | |
| 1050 | assert f1.size() == len(f2.getvalue()) |
| 1051 | |
| 1052 | # Do the same test with a table |
| 1053 | record_batch = pa.RecordBatch.from_arrays([pa.array([1, 2, 3])], ['a']) |
| 1054 | |
| 1055 | f1 = pa.MockOutputStream() |
| 1056 | f2 = pa.BufferOutputStream() |
| 1057 | |
| 1058 | stream_writer1 = pa.RecordBatchStreamWriter(f1, record_batch.schema) |
| 1059 | stream_writer2 = pa.RecordBatchStreamWriter(f2, record_batch.schema) |
| 1060 | |
| 1061 | stream_writer1.write_batch(record_batch) |
| 1062 | stream_writer2.write_batch(record_batch) |
| 1063 | stream_writer1.close() |
| 1064 | stream_writer2.close() |
| 1065 | |
| 1066 | assert f1.size() == len(f2.getvalue()) |
| 1067 | |
| 1068 | |
| 1069 | # ---------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected