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

Function _check_native_file_reader

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

Source from the content-addressed store, hash-verified

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