Skip to content

Commit

Permalink
TST: Add test for C parser handling binary mode (#24797)
Browse files Browse the repository at this point in the history
Python's native CSV library doesn't accept such
files, but we do for the C parser.

Closes gh-23779.
  • Loading branch information
gfyoung committed Jan 16, 2019
1 parent 0bf62b3 commit 17a6bc5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pandas/tests/io/parser/test_c_parser_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,17 @@ def test_file_handles_mmap(c_parser_only, csv1):
if PY3:
assert not m.closed
m.close()


def test_file_binary_mode(c_parser_only):
# see gh-23779
parser = c_parser_only
expected = DataFrame([[1, 2, 3], [4, 5, 6]])

with tm.ensure_clean() as path:
with open(path, "w") as f:
f.write("1,2,3\n4,5,6")

with open(path, "rb") as f:
result = parser.read_csv(f, header=None)
tm.assert_frame_equal(result, expected)

0 comments on commit 17a6bc5

Please sign in to comment.