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

Function test_native_file_TextIOWrapper

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

Source from the content-addressed store, hash-verified

1400
1401
1402def test_native_file_TextIOWrapper(tmpdir):
1403 data = ('foooo\n'
1404 'barrr\n'
1405 'bazzz\n')
1406
1407 path = os.path.join(str(tmpdir), guid())
1408 with open(path, 'wb') as f:
1409 f.write(data.encode('utf-8'))
1410
1411 with TextIOWrapper(pa.OSFile(path, mode='rb')) as fil:
1412 assert fil.readable()
1413 res = fil.read()
1414 assert res == data
1415 assert fil.closed
1416
1417 with TextIOWrapper(pa.OSFile(path, mode='rb')) as fil:
1418 # Iteration works
1419 lines = list(fil)
1420 assert ''.join(lines) == data
1421
1422 # Writing
1423 path2 = os.path.join(str(tmpdir), guid())
1424 with TextIOWrapper(pa.OSFile(path2, mode='wb')) as fil:
1425 assert fil.writable()
1426 fil.write(data)
1427
1428 with TextIOWrapper(pa.OSFile(path2, mode='rb')) as fil:
1429 res = fil.read()
1430 assert res == data
1431
1432
1433def test_native_file_TextIOWrapper_perf(tmpdir):

Callers

nothing calls this directly

Calls 7

guidFunction · 0.90
listFunction · 0.85
writableMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45
encodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected