| 1400 | |
| 1401 | |
| 1402 | def 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 | |
| 1433 | def test_native_file_TextIOWrapper_perf(tmpdir): |