(FACTORY, sample_data,
allow_read_out_of_bounds=True)
| 1089 | |
| 1090 | |
| 1091 | def _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 | |
| 1124 | def test_memory_map_reader(sample_disk_data): |
no test coverage detected