mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #23171: csv.Writer.writerow() now supports arbitrary iterables.
This commit is contained in:
parent
a695f83f0d
commit
7901b48a1f
5 changed files with 54 additions and 46 deletions
|
@ -186,6 +186,14 @@ class Test_Csv(unittest.TestCase):
|
|||
self._write_test(['a',1,'p,q'], 'a,1,p\\,q',
|
||||
escapechar='\\', quoting = csv.QUOTE_NONE)
|
||||
|
||||
def test_write_iterable(self):
|
||||
self._write_test(iter(['a', 1, 'p,q']), 'a,1,"p,q"')
|
||||
self._write_test(iter(['a', 1, None]), 'a,1,')
|
||||
self._write_test(iter([]), '')
|
||||
self._write_test(iter([None]), '""')
|
||||
self._write_error_test(csv.Error, iter([None]), quoting=csv.QUOTE_NONE)
|
||||
self._write_test(iter([None, None]), ',')
|
||||
|
||||
def test_writerows(self):
|
||||
class BrokenFile:
|
||||
def write(self, buf):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue