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

Function test_os_file_writer

python/pyarrow/tests/test_io.py:1265–1289  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1263
1264
1265def test_os_file_writer(tmpdir):
1266 SIZE = 4096
1267 arr = [random.randint(0, 255) for _ in range(SIZE)]
1268 data = bytes(arr[:SIZE])
1269
1270 path = os.path.join(str(tmpdir), guid())
1271 with open(path, 'wb') as f:
1272 f.write(data)
1273
1274 # Truncates file
1275 f2 = pa.OSFile(path, mode='w')
1276 f2.write(b'foo')
1277
1278 with pa.OSFile(path) as f3:
1279 assert f3.size() == 3
1280
1281 with pytest.raises(IOError):
1282 f2.read(5)
1283 f2.close()
1284
1285 # Append
1286 with pa.OSFile(path, mode='ab') as f4:
1287 f4.write(b'bar')
1288 with pa.OSFile(path) as f5:
1289 assert f5.size() == 6 # foo + bar
1290
1291
1292def test_os_file_raw_fd(tmpdir):

Callers

nothing calls this directly

Calls 7

guidFunction · 0.90
bytesFunction · 0.85
joinMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected