Merge pull request #295 from josteinl/csv_every_field_on_new_line

Fix problem with csv writer writing every field on own line, if not h…
This commit is contained in:
Romain Dorgueil
2018-10-28 18:51:47 +01:00
committed by GitHub
2 changed files with 3 additions and 12 deletions

View File

@ -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

View File

@ -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() == ('', '', '')