Skip to content

Commit a715d9c

Browse files
committed
TST/DOC applied TomAugspurger's feedback
* Added test for new test util `convert_rows_list_to_csv_str` * Edited what's new Related Issue: pandas-dev#20353
1 parent 3f9c070 commit a715d9c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ Other Enhancements
187187

188188
Backwards incompatible API changes
189189
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190-
- When file path is given by string format in :func:`DataFrame.to_csv`, it disables universal newline support.
191-
- Instead, default value of `line_terminator` in :func:`DataFrame.to_csv` has changed from `'\n'` to `os.linesep`(:issue:`20353`)
190+
- :func:`DataFrame.to_csv` now uses :func:`os.linesep` rather than ``'\n'`` for the default line terminator.(:issue:`20353`)
192191

193192

194193
.. _whatsnew_0240.api_breaking.interval_values:

pandas/tests/io/formats/test_to_csv.py

-6
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ def test_to_csv_string_with_lf(self):
360360
b'2,"d\nef"' + os_linesep +
361361
b'3,"g\nh\n\ni"' + os_linesep
362362
)
363-
364363
df.to_csv(path, index=False)
365364
with open(path, 'rb') as f:
366365
assert f.read() == expected_noarg
@@ -373,7 +372,6 @@ def test_to_csv_string_with_lf(self):
373372
b'2,"d\nef"\n'
374373
b'3,"g\nh\n\ni"\n'
375374
)
376-
377375
df.to_csv(path, line_terminator='\n', index=False)
378376
with open(path, 'rb') as f:
379377
assert f.read() == expected_lf
@@ -387,7 +385,6 @@ def test_to_csv_string_with_lf(self):
387385
b'2,"d\nef"\r\n'
388386
b'3,"g\nh\n\ni"\r\n'
389387
)
390-
391388
df.to_csv(path, line_terminator='\r\n', index=False)
392389
with open(path, 'rb') as f:
393390
assert f.read() == expected_crlf
@@ -409,7 +406,6 @@ def test_to_csv_string_with_crlf(self):
409406
b'2,"d\r\nef"' + os_linesep +
410407
b'3,"g\r\nh\r\n\r\ni"' + os_linesep
411408
)
412-
413409
df.to_csv(path, index=False)
414410
with open(path, 'rb') as f:
415411
assert f.read() == expected_noarg
@@ -422,7 +418,6 @@ def test_to_csv_string_with_crlf(self):
422418
b'2,"d\r\nef"\n'
423419
b'3,"g\r\nh\r\n\r\ni"\n'
424420
)
425-
426421
df.to_csv(path, line_terminator='\n', index=False)
427422
with open(path, 'rb') as f:
428423
assert f.read() == expected_lf
@@ -436,7 +431,6 @@ def test_to_csv_string_with_crlf(self):
436431
b'2,"d\r\nef"\r\n'
437432
b'3,"g\r\nh\r\n\r\ni"\r\n'
438433
)
439-
440434
df.to_csv(path, line_terminator='\r\n', index=False)
441435
with open(path, 'rb') as f:
442436
assert f.read() == expected_crlf

pandas/tests/util/test_testing.py

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
assert_index_equal, assert_series_equal,
1313
assert_frame_equal, assert_numpy_array_equal,
1414
RNGContext)
15+
from pandas import compat
1516

1617

1718
class TestAssertAlmostEqual(object):
@@ -164,6 +165,15 @@ def test_raise_with_traceback(self):
164165
_, _, traceback = sys.exc_info()
165166
raise_with_traceback(e, traceback)
166167

168+
def test_convert_rows_list_to_csv_str(self):
169+
rows_list = ["aaa", "bbb", "ccc"]
170+
ret = tm.convert_rows_list_to_csv_str(rows_list)
171+
if(compat.is_platform_windows()):
172+
expected = "aaa\r\nbbb\r\nccc\r\n"
173+
else:
174+
expected = "aaa\nbbb\nccc\n"
175+
assert ret == expected
176+
167177

168178
class TestAssertNumpyArrayEqual(object):
169179

0 commit comments

Comments
 (0)