Skip to content

Commit 17a6bc5

Browse files
authored
TST: Add test for C parser handling binary mode (#24797)
Python's native CSV library doesn't accept such files, but we do for the C parser. Closes gh-23779.
1 parent 0bf62b3 commit 17a6bc5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/io/parser/test_c_parser_only.py

+14
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,17 @@ def test_file_handles_mmap(c_parser_only, csv1):
575575
if PY3:
576576
assert not m.closed
577577
m.close()
578+
579+
580+
def test_file_binary_mode(c_parser_only):
581+
# see gh-23779
582+
parser = c_parser_only
583+
expected = DataFrame([[1, 2, 3], [4, 5, 6]])
584+
585+
with tm.ensure_clean() as path:
586+
with open(path, "w") as f:
587+
f.write("1,2,3\n4,5,6")
588+
589+
with open(path, "rb") as f:
590+
result = parser.read_csv(f, header=None)
591+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)