()
| 217 | |
| 218 | |
| 219 | def test_python_file_read_buffer(): |
| 220 | length = 10 |
| 221 | data = b'0123456798' |
| 222 | dst_buf = bytearray(data) |
| 223 | |
| 224 | class DuckReader: |
| 225 | def close(self): |
| 226 | pass |
| 227 | |
| 228 | @property |
| 229 | def closed(self): |
| 230 | return False |
| 231 | |
| 232 | def read_buffer(self, nbytes): |
| 233 | assert nbytes == length |
| 234 | return memoryview(dst_buf)[:nbytes] |
| 235 | |
| 236 | duck_reader = DuckReader() |
| 237 | with pa.PythonFile(duck_reader, mode='r') as f: |
| 238 | buf = f.read_buffer(length) |
| 239 | assert len(buf) == length |
| 240 | assert memoryview(buf).tobytes() == dst_buf[:length] |
| 241 | # buf should point to the same memory, so modifying it |
| 242 | memoryview(buf)[0] = ord(b'x') |
| 243 | # should modify the original |
| 244 | assert dst_buf[0] == ord(b'x') |
| 245 | |
| 246 | |
| 247 | def test_python_file_correct_abc(): |
nothing calls this directly
no test coverage detected