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

Function test_os_file_writer

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

Source from the content-addressed store, hash-verified

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

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