From 07160cdcccedd49451bd04fff9e1fd9969a83ac1 Mon Sep 17 00:00:00 2001 From: Jostein Leira Date: Sat, 27 Oct 2018 16:24:21 +0200 Subject: [PATCH] Fix problem with csv writer writing every field on own line, if not header information. Update tests to accommodate change. --- bonobo/nodes/io/csv.py | 3 +-- tests/nodes/io/test_csv.py | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/bonobo/nodes/io/csv.py b/bonobo/nodes/io/csv.py index c97407f..4841896 100644 --- a/bonobo/nodes/io/csv.py +++ b/bonobo/nodes/io/csv.py @@ -126,8 +126,7 @@ class CsvWriter(FileWriter, CsvHandler): ) context.writer(values) else: - for arg in values: - context.writer(ensure_tuple(arg)) + context.writer(ensure_tuple(values)) return NOT_MODIFIED diff --git a/tests/nodes/io/test_csv.py b/tests/nodes/io/test_csv.py index 3173768..7ed8476 100644 --- a/tests/nodes/io/test_csv.py +++ b/tests/nodes/io/test_csv.py @@ -100,7 +100,7 @@ class CsvWriterTest(Csv, WriterTest, TestCase): @incontext() def test_nofields_multiple_args(self, context): # multiple args are iterated onto and flattened in output - context.write_sync((L1, L2), (L3, L4)) + context.write_sync(L1, L2, L3, L4) context.stop() assert self.readlines() == ("a,hey", "b,bee", "c,see", "d,dee") @@ -111,18 +111,10 @@ class CsvWriterTest(Csv, WriterTest, TestCase): with pytest.raises(TypeError): context.write_sync((L1, L2), (L3,)) - @incontext() - def test_nofields_single_arg(self, context): - # single args are just dumped, shapes can vary. - context.write_sync((L1,), (LL,), (L3,)) - context.stop() - - assert self.readlines() == ("a,hey", "i,have,more,values", "c,see") - @incontext() def test_nofields_empty_args(self, context): # empty calls are ignored context.write_sync(EMPTY, EMPTY, EMPTY) context.stop() - assert self.readlines() == () + assert self.readlines() == ('', '', '')