summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Monthe <anthony.monthe@gmail.com>2019-06-27 23:19:06 +0100
committerAnthony Monthe <anthony.monthe@gmail.com>2019-06-27 23:19:06 +0100
commit513bba2c20ce192248014e712bdbeeaebfb6d3bd (patch)
tree5b79541e29628642f2a63fa0d2844b7b0d0278f1
parentf55f56ae1d5d5fb22dcf0b20fc2bbff62c86a76c (diff)
downloadtablib-513bba2c20ce192248014e712bdbeeaebfb6d3bd.tar.gz
Added CSV stream test
-rw-r--r--.gitignore1
-rwxr-xr-xtest_tablib.py20
2 files changed, 20 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 379075b..d6fdabd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,4 @@ junit-py27.xml
# pyenv noise
.python-version
+tablib.egg-info/*
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."""