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

Function test_os_file_writer

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

Source from the content-addressed store, hash-verified

1255
1256
1257def test_os_file_writer(tmpdir):
1258 SIZE = 4096
1259 arr = [random.randint(0, 255) for _ in range(SIZE)]
1260 data = bytes(arr[:SIZE])
1261
1262 path = os.path.join(str(tmpdir), guid())
1263 with open(path, 'wb') as f:
1264 f.write(data)
1265
1266 # Truncates file
1267 f2 = pa.OSFile(path, mode='w')
1268 f2.write(b'foo')
1269
1270 with pa.OSFile(path) as f3:
1271 assert f3.size() == 3
1272
1273 with pytest.raises(IOError):
1274 f2.read(5)
1275 f2.close()
1276
1277 # Append
1278 with pa.OSFile(path, mode='ab') as f4:
1279 f4.write(b'bar')
1280 with pa.OSFile(path) as f5:
1281 assert f5.size() == 6 # foo + bar
1282
1283
1284def 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