Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c907f6f

Browse files
author
y-p
committed
TST: add test for UnicodeWriter with csv.QUOTE_NONNUMERIC
1 parent c9c0f95 commit c907f6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_frame.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,6 +3530,23 @@ def test_to_csv_quoting(self):
35303530

35313531
self.assertEqual(result, expected)
35323532

3533+
def test_to_csv_unicodewriter_quoting(self):
3534+
import csv
3535+
3536+
df = DataFrame({'A': [1, 2, 3], 'B': ['foo', 'bar', 'baz']})
3537+
3538+
buf = StringIO()
3539+
df.to_csv(buf, index=False, quoting=csv.QUOTE_NONNUMERIC,
3540+
encoding = 'utf-8')
3541+
3542+
result = buf.getvalue()
3543+
expected = ('"A","B"\n'
3544+
'1,"foo"\n'
3545+
'2,"bar"\n'
3546+
'3,"baz"\n')
3547+
3548+
self.assertEqual(result, expected)
3549+
35333550
def test_to_csv_index_no_leading_comma(self):
35343551
df = DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]},
35353552
index=['one', 'two', 'three'])

0 commit comments

Comments
 (0)