Skip to content

Commit 863c59e

Browse files
committed
TST: Add to_csv test for writing the single column CSV
1 parent be66ef8 commit 863c59e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pandas/tests/io/formats/test_to_csv.py

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
import sys
34
import numpy as np
45
import pandas as pd
56
import pytest
@@ -9,6 +10,34 @@
910

1011
class TestToCSV(object):
1112

13+
@pytest.mark.xfail((3, 6, 5) > sys.version_info >= (3, 5),
14+
reason='Python csv library bug')
15+
def test_to_csv_with_single_column(self):
16+
# GH18676
17+
df1 = DataFrame([None, 1],
18+
header=None,
19+
index=None)
20+
expected1 = """\
21+
""
22+
1
23+
"""
24+
with tm.ensure_clean('test.csv') as path:
25+
df1.to_csv(path, header=None, index=None)
26+
with open(path, 'r') as f:
27+
assert f.read() == expected1
28+
29+
df2 = DataFrame([1, None],
30+
header=None,
31+
index=None)
32+
expected2 = """\
33+
1
34+
""
35+
"""
36+
with tm.ensure_clean('test.csv') as path:
37+
df2.to_csv(path, header=None, index=None)
38+
with open(path, 'r') as f:
39+
assert f.read() == expected2
40+
1241
def test_to_csv_defualt_encoding(self):
1342
# GH17097
1443
df = DataFrame({'col': [u"AAAAA", u"ÄÄÄÄÄ", u"ßßßßß", u"聞聞聞聞聞"]})

0 commit comments

Comments
 (0)