| 1425 | |
| 1426 | |
| 1427 | def test_native_file_TextIOWrapper(tmpdir): |
| 1428 | data = ('foooo\n' |
| 1429 | 'barrr\n' |
| 1430 | 'bazzz\n') |
| 1431 | |
| 1432 | path = os.path.join(str(tmpdir), guid()) |
| 1433 | with open(path, 'wb') as f: |
| 1434 | f.write(data.encode('utf-8')) |
| 1435 | |
| 1436 | with TextIOWrapper(pa.OSFile(path, mode='rb')) as fil: |
| 1437 | assert fil.readable() |
| 1438 | res = fil.read() |
| 1439 | assert res == data |
| 1440 | assert fil.closed |
| 1441 | |
| 1442 | with TextIOWrapper(pa.OSFile(path, mode='rb')) as fil: |
| 1443 | # Iteration works |
| 1444 | lines = list(fil) |
| 1445 | assert ''.join(lines) == data |
| 1446 | |
| 1447 | # Writing |
| 1448 | path2 = os.path.join(str(tmpdir), guid()) |
| 1449 | with TextIOWrapper(pa.OSFile(path2, mode='wb')) as fil: |
| 1450 | assert fil.writable() |
| 1451 | fil.write(data) |
| 1452 | |
| 1453 | with TextIOWrapper(pa.OSFile(path2, mode='rb')) as fil: |
| 1454 | res = fil.read() |
| 1455 | assert res == data |
| 1456 | |
| 1457 | |
| 1458 | def test_native_file_TextIOWrapper_perf(tmpdir): |