Skip to content

Commit 662229d

Browse files
Add a test for the errors argument in to_csv()
1 parent 63aca8d commit 662229d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/io/formats/test_to_csv.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,13 @@ def test_na_rep_truncated(self):
597597
result = pd.Series([1.1, 2.2]).to_csv(na_rep=".")
598598
expected = tm.convert_rows_list_to_csv_str([",0", "0,1.1", "1,2.2"])
599599
assert result == expected
600+
601+
@pytest.mark.parametrize("errors", ["surrogatepass", "ignore", "replace"])
602+
def test_to_csv_errors(self, errors):
603+
# GH 22610
604+
data = ['\ud800foo']
605+
ser = pd.Series(data, index=pd.Index(data))
606+
with tm.ensure_clean("test.csv") as path:
607+
ser.to_csv(path, errors=errors)
608+
# No use in reading back the data as it is not the same anymore
609+
# due to the error handling

0 commit comments

Comments
 (0)