From 2e9195f953a35d4bf5a46d2cbbff8de597aef125 Mon Sep 17 00:00:00 2001 From: Kunal Khandelwal Date: Mon, 25 Jun 2018 18:03:18 +0530 Subject: [PATCH] added test for tsv import --- tests/core/exports/books-mac.tsv | 2 ++ tests/core/tests/test_base_formats.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/core/exports/books-mac.tsv diff --git a/tests/core/exports/books-mac.tsv b/tests/core/exports/books-mac.tsv new file mode 100644 index 0000000..1cc5de4 --- /dev/null +++ b/tests/core/exports/books-mac.tsv @@ -0,0 +1,2 @@ +id name author_email +1 Some book test@example.com diff --git a/tests/core/tests/test_base_formats.py b/tests/core/tests/test_base_formats.py index 003b633..3a59377 100644 --- a/tests/core/tests/test_base_formats.py +++ b/tests/core/tests/test_base_formats.py @@ -79,7 +79,18 @@ class CSVTest(TestCase): class TSVTest(TestCase): def setUp(self): - self.format = base_formats.CSV() + self.format = base_formats.TSV() + + def test_import_mac(self): + filename = os.path.join( + os.path.dirname(__file__), + os.path.pardir, + 'exports', + 'books-mac.tsv') + with open(filename, self.format.get_read_mode()) as in_stream: + actual = in_stream.read() + expected = 'id\tname\tauthor_email\n1\tSome book\ttest@example.com\n' + self.assertEqual(actual, expected) def test_import_unicode(self): # importing tsv UnicodeEncodeError @@ -90,4 +101,4 @@ class TSVTest(TestCase): 'books-unicode.tsv') with open(filename, self.format.get_read_mode()) as in_stream: data = force_text(in_stream.read()) - base_formats.CSV().create_dataset(data) + base_formats.TSV().create_dataset(data)