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:
@ -126,8 +126,7 @@ class CsvWriter(FileWriter, CsvHandler):
|
|||||||
)
|
)
|
||||||
context.writer(values)
|
context.writer(values)
|
||||||
else:
|
else:
|
||||||
for arg in values:
|
context.writer(ensure_tuple(values))
|
||||||
context.writer(ensure_tuple(arg))
|
|
||||||
|
|
||||||
return NOT_MODIFIED
|
return NOT_MODIFIED
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ class CsvWriterTest(Csv, WriterTest, TestCase):
|
|||||||
@incontext()
|
@incontext()
|
||||||
def test_nofields_multiple_args(self, context):
|
def test_nofields_multiple_args(self, context):
|
||||||
# multiple args are iterated onto and flattened in output
|
# 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()
|
context.stop()
|
||||||
|
|
||||||
assert self.readlines() == ("a,hey", "b,bee", "c,see", "d,dee")
|
assert self.readlines() == ("a,hey", "b,bee", "c,see", "d,dee")
|
||||||
@ -111,18 +111,10 @@ class CsvWriterTest(Csv, WriterTest, TestCase):
|
|||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
context.write_sync((L1, L2), (L3,))
|
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()
|
@incontext()
|
||||||
def test_nofields_empty_args(self, context):
|
def test_nofields_empty_args(self, context):
|
||||||
# empty calls are ignored
|
# empty calls are ignored
|
||||||
context.write_sync(EMPTY, EMPTY, EMPTY)
|
context.write_sync(EMPTY, EMPTY, EMPTY)
|
||||||
context.stop()
|
context.stop()
|
||||||
|
|
||||||
assert self.readlines() == ()
|
assert self.readlines() == ('', '', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user