Skip to content

Commit 6e725bc

Browse files
committed
TST: Add to_csv defualt encoding test
1 parent c9c96a9 commit 6e725bc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/io/formats/test_to_csv.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
from pandas import DataFrame
24
import numpy as np
35
import pandas as pd
@@ -6,6 +8,18 @@
68

79
class TestToCSV(object):
810

11+
def test_to_csv_defualt_encoding(self):
12+
# GH17097
13+
df = DataFrame({'col': [u"AAAAA", u"ÄÄÄÄÄ", u"ßßßßß", u"聞聞聞聞聞"]})
14+
15+
with tm.ensure_clean('test.csv') as path:
16+
if pd.compat.PY2:
17+
with tm.assert_raises_regex(UnicodeEncodeError, 'ascii'):
18+
df.to_csv(path)
19+
else:
20+
df.to_csv(path)
21+
tm.assert_frame_equal(pd.read_csv(path, index_col=0), df)
22+
923
def test_to_csv_quotechar(self):
1024
df = DataFrame({'col': [1, 2]})
1125
expected = """\

0 commit comments

Comments
 (0)