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

Function check_large_seeks

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

Source from the content-addressed store, hash-verified

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