diff --git a/tests/fixtures/generic/csv-doubleqouted-streaming.json b/tests/fixtures/generic/csv-doubleqouted-streaming.json new file mode 100644 index 00000000..9f0e1ded --- /dev/null +++ b/tests/fixtures/generic/csv-doubleqouted-streaming.json @@ -0,0 +1 @@ +[{"A":"1","B":"this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this is 1024 bytes long field this"},{"A":"2","B":"this is a field with \" in it\""}] diff --git a/tests/test_csv_s.py b/tests/test_csv_s.py index 5a9707ce..757d7cfc 100644 --- a/tests/test_csv_s.py +++ b/tests/test_csv_s.py @@ -42,6 +42,9 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records.csv'), 'r', encoding='utf-8') as f: self.generic_csv_10k_sales_records = f.read() + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doubleqouted.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_doubleqouted = f.read() + # output with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats-streaming.json'), 'r', encoding='utf-8') as f: self.generic_csv_biostats_streaming_json = json.loads(f.read()) @@ -70,6 +73,9 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records-streaming.json'), 'r', encoding='utf-8') as f: self.generic_csv_10k_sales_records_streaming_json = json.loads(f.read()) + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doubleqouted-streaming.json'), 'r', encoding='utf-8') as f: + self.generic_csv_doublequoted_streaming_json = json.loads(f.read()) + def test_csv_s_nodata(self): """ Test CSV parser with no data @@ -141,6 +147,12 @@ class MyTests(unittest.TestCase): """ self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_10k_sales_records.splitlines(), quiet=True)), self.generic_csv_10k_sales_records_streaming_json) + def test_csv_s_doublequoted(self): + """ + Test 'doublequoted.csv' file + """ + self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_doubleqouted.splitlines(), quiet=True)), self.generic_csv_doublequoted_streaming_json) + if __name__ == '__main__': unittest.main()