diff options
| author | Frost Ming <mianghong@gmail.com> | 2019-06-28 09:02:43 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-28 09:02:43 +0800 |
| commit | d25d24a9bb1ef0479e800aacbe6ae7dd9e6e35c2 (patch) | |
| tree | d5e1b8fad11c09e97ccb90e6eec3fbb5bb0b452a /test_tablib.py | |
| parent | 2b9ce02e3c2b46dcd323db37d2e8e0c65cdd7a5d (diff) | |
| parent | 513bba2c20ce192248014e712bdbeeaebfb6d3bd (diff) | |
| download | tablib-d25d24a9bb1ef0479e800aacbe6ae7dd9e6e35c2.tar.gz | |
Merge pull request #337 from ZuluPro/stream
Added stream to CSV
Diffstat (limited to 'test_tablib.py')
| -rwxr-xr-x | test_tablib.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test_tablib.py b/test_tablib.py index e7b7233..6e3bc60 100755 --- a/test_tablib.py +++ b/test_tablib.py @@ -13,7 +13,7 @@ from uuid import uuid4 import tablib from tablib.compat import markup, unicode, is_py3 from tablib.core import Row -from tablib.formats import csv as csv_format +from tablib.formats import _csv as csv_module class TablibTestCase(unittest.TestCase): @@ -262,6 +262,24 @@ class TablibTestCase(unittest.TestCase): self.assertEqual(csv, self.founders.csv) + def test_csv_stream_export(self): + """Verify exporting dataset object as CSV from file object.""" + + # Build up the csv string with headers first, followed by each row + csv = '' + for col in self.headers: + csv += col + ',' + + csv = csv.strip(',') + '\r\n' + + for founder in self.founders: + for col in founder: + csv += str(col) + ',' + csv = csv.strip(',') + '\r\n' + + csv_stream = csv_module.export_stream_set(self.founders) + self.assertEqual(csv, csv_stream.getvalue()) + def test_tsv_export(self): """Verify exporting dataset object as TSV.""" |
