|
3 | 3 | import csv
|
4 | 4 | import os
|
5 | 5 | import platform
|
| 6 | +from io import BytesIO |
6 | 7 |
|
7 | 8 | import re
|
8 | 9 | import sys
|
@@ -1474,18 +1475,11 @@ def test_memory_map(self):
|
1474 | 1475 |
|
1475 | 1476 | def test_read_csv_utf_aliases(self):
|
1476 | 1477 | # see gh issue 13549
|
1477 |
| - path = 'test.csv' |
1478 |
| - expected = DataFrame({'A': [0, 1], 'B': [2, 3], |
1479 |
| - 'multibyte_test': ['testing123', 'bananabis'], |
1480 |
| - 'mb_nums': [154.868, 457.8798]}) |
1481 |
| - with tm.ensure_clean(path) as path: |
1482 |
| - for byte in [8, 16]: |
1483 |
| - expected.to_csv(path, encoding='utf-' + str(byte), index=False) |
1484 |
| - for fmt in ['utf-{0}', 'utf_{0}', 'UTF-{0}', 'UTF_{0}']: |
1485 |
| - encoding = fmt.format(byte) |
1486 |
| - for engine in ['c', 'python', None]: |
1487 |
| - result = self.read_csv( |
1488 |
| - path, |
1489 |
| - engine=engine, |
1490 |
| - encoding=encoding) |
1491 |
| - tm.assert_frame_equal(result, expected) |
| 1478 | + expected = pd.DataFrame({'mb_num': [4.8], 'multibyte': ['test']}) |
| 1479 | + for byte in [8, 16]: |
| 1480 | + expected.to_csv(path, encoding='utf-' + str(byte), index=False) |
| 1481 | + for fmt in ['utf-{0}', 'utf_{0}', 'UTF-{0}', 'UTF_{0}']: |
| 1482 | + encoding = fmt.format(byte) |
| 1483 | + data = 'mb_num,multibyte\n4.8,test'.encode(encoding) |
| 1484 | + result = self.read_csv(BytesIO(data), encoding=encoding) |
| 1485 | + tm.assert_frame_equal(result, expected) |
0 commit comments