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