Skip to content

Commit

Permalink
added newline kwarg to StringIO (jazzband#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhegarty committed Feb 21, 2022
1 parent d9a4a97 commit 1e58df6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tablib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def normalize_input(stream):
file-like object.
"""
if isinstance(stream, str):
return StringIO(stream)
return StringIO(stream, newline='')
elif isinstance(stream, bytes):
return BytesIO(stream)
return stream
8 changes: 8 additions & 0 deletions tests/test_tablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,14 @@ def test_csv_import_set_skip_lines(self):
dataset = tablib.import_set(csv_text, format="csv", skip_lines=2)
self.assertEqual(dataset.headers, ['id', 'name','description'])

def test_csv_import_mac_os_lf(self):
csv_text = (
'id,name,description\r'
'12,Smith,rounded\r'
)
dataset = tablib.import_set(csv_text, format="csv")
self.assertEqual(dataset.headers, ['id', 'name','description'])

def test_csv_export(self):
"""Verify exporting dataset object as CSV."""

Expand Down

0 comments on commit 1e58df6

Please sign in to comment.