Skip to content

Commit 1f41f01

Browse files
author
y-p
committed
TST: really fix bytes/text issue in py3 failing test
1 parent d97766a commit 1f41f01

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

pandas/io/tests/test_parsers.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,18 +1333,25 @@ def test_sniff_delimiter(self):
13331333
sep=None, skiprows=2)
13341334
tm.assert_frame_equal(data, data3)
13351335

1336-
# can't get this to work on Python 3
1337-
if not py3compat.PY3:
1338-
text = u"""ignore this
1336+
1337+
text = u"""ignore this
13391338
ignore this too
13401339
index|A|B|C
13411340
foo|1|2|3
13421341
bar|4|5|6
13431342
baz|7|8|9
13441343
""".encode('utf-8')
1345-
data4 = self.read_csv(BytesIO(text), index_col=0, sep=None, skiprows=2,
1346-
encoding='utf-8')
1347-
tm.assert_frame_equal(data, data4)
1344+
1345+
s = BytesIO(text)
1346+
if py3compat.PY3:
1347+
# somewhat False since the code never sees bytes
1348+
from io import TextIOWrapper
1349+
s =TextIOWrapper(s, encoding='utf-8')
1350+
1351+
1352+
data4 = self.read_csv(s, index_col=0, sep=None, skiprows=2,
1353+
encoding='utf-8')
1354+
tm.assert_frame_equal(data, data4)
13481355

13491356
def test_regex_separator(self):
13501357
data = """ A B C D
@@ -1604,10 +1611,11 @@ def test_utf16_bom_skiprows(self):
16041611
with open(path, 'wb') as f:
16051612
f.write(bytes)
16061613

1614+
s = BytesIO(dat.encode('utf-8'))
16071615
if py3compat.PY3:
1608-
s = BytesIO(dat.encode('utf-8'))
1609-
else:
1610-
s = StringIO(dat.encode('utf-8'))
1616+
# somewhat False since the code never sees bytes
1617+
from io import TextIOWrapper
1618+
s =TextIOWrapper(s, encoding='utf-8')
16111619

16121620
result = self.read_csv(path, encoding=enc, skiprows=2,
16131621
sep=sep)

0 commit comments

Comments
 (0)