MCPcopy Create free account
hub / github.com/apache/arrow / _check_native_file_reader

Function _check_native_file_reader

python/pyarrow/tests/test_io.py:1091–1121  ·  view source on GitHub ↗
(FACTORY, sample_data,
                              allow_read_out_of_bounds=True)

Source from the content-addressed store, hash-verified

1089
1090
1091def _check_native_file_reader(FACTORY, sample_data,
1092 allow_read_out_of_bounds=True):
1093 path, data = sample_data
1094
1095 f = FACTORY(path, mode='r')
1096
1097 assert f.read(10) == data[:10]
1098 assert f.read(0) == b''
1099 assert f.tell() == 10
1100
1101 assert f.read() == data[10:]
1102
1103 assert f.size() == len(data)
1104
1105 f.seek(0)
1106 assert f.tell() == 0
1107
1108 # Seeking past end of file not supported in memory maps
1109 if allow_read_out_of_bounds:
1110 f.seek(len(data) + 1)
1111 assert f.tell() == len(data) + 1
1112 assert f.read(5) == b''
1113
1114 # Test whence argument of seek, ARROW-1287
1115 assert f.seek(3) == 3
1116 assert f.seek(3, os.SEEK_CUR) == 6
1117 assert f.tell() == 6
1118
1119 ex_length = len(data) - 2
1120 assert f.seek(-2, os.SEEK_END) == ex_length
1121 assert f.tell() == ex_length
1122
1123
1124def test_memory_map_reader(sample_disk_data):

Callers 2

test_memory_map_readerFunction · 0.85
test_os_file_readerFunction · 0.85

Calls 4

lenFunction · 0.85
seekMethod · 0.80
readMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected