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

Function check_large_seeks

python/pyarrow/tests/test_io.py:44–64  ·  view source on GitHub ↗
(file_factory, expected_error=None)

Source from the content-addressed store, hash-verified

42
43
44def check_large_seeks(file_factory, expected_error=None):
45 if sys.platform in ('win32', 'darwin', 'emscripten'):
46 pytest.skip("need sparse file support")
47 try:
48 filename = tempfile.mktemp(prefix='test_io')
49 with open(filename, 'wb') as f:
50 f.truncate(2 ** 32 + 10)
51 f.seek(2 ** 32 + 5)
52 f.write(b'mark\n')
53 if expected_error:
54 with expected_error:
55 file_factory(filename)
56 else:
57 with file_factory(filename) as f:
58 assert f.size() == 2 ** 32 + 10
59 assert f.seek(2 ** 32 + 5) == 2 ** 32 + 5
60 assert f.tell() == 2 ** 32 + 5
61 assert f.read(5) == b'mark\n'
62 assert f.tell() == 2 ** 32 + 10
63 finally:
64 os.unlink(filename)
65
66
67@contextmanager

Callers 3

test_os_file_large_seeksFunction · 0.85

Calls 4

seekMethod · 0.80
writeMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected