Skip to content

Commit d740009

Browse files
kinowBruno P. Kinoshita
authored andcommitted
Use StringIO instead of capturing sys out
1 parent 95ce8f1 commit d740009

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/tests/io/formats/test_to_csv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,10 @@ def test_to_csv_na_rep_long_string(self, capsys):
526526
'mynull',
527527
'mynull',
528528
'mynull']
529-
expected_ascii = tm.convert_rows_list_to_csv_str(expected_rows)
529+
expected = tm.convert_rows_list_to_csv_str(expected_rows)
530530

531-
df.to_csv(sys.stdout, index=False, na_rep='mynull', encoding='ascii')
532-
captured = capsys.readouterr()
531+
csv_data = StringIO()
532+
df.to_csv(csv_data, index=False, na_rep='mynull', encoding='ascii')
533+
result = csv_data.getvalue()
533534

534-
assert captured.out == expected_ascii
535-
assert not sys.stdout.closed
535+
assert expected == result

0 commit comments

Comments
 (0)