[Python-checkins] cpython: Issue #18727: improve test coverage of the csv module by testing for
antoine.pitrou
python-checkins at python.org
Tue Apr 29 01:58:39 CEST 2014
http://hg.python.org/cpython/rev/2502843dbedf
changeset: 90494:2502843dbedf
user: Antoine Pitrou <solipsis at pitrou.net>
date: Tue Apr 29 01:58:06 2014 +0200
summary:
Issue #18727: improve test coverage of the csv module by testing for DictWriter.writerows.
Patch by Muhammad Jehanzeb.
files:
Lib/test/test_csv.py | 10 ++++++++++
Misc/ACKS | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -575,6 +575,16 @@
fileobj.readline() # header
self.assertEqual(fileobj.read(), "10,,abc\r\n")
+ def test_write_multiple_dict_rows(self):
+ fileobj = StringIO()
+ writer = csv.DictWriter(fileobj, fieldnames=["f1", "f2", "f3"])
+ writer.writeheader()
+ self.assertEqual(fileobj.getvalue(), "f1,f2,f3\r\n")
+ writer.writerows([{"f1": 1, "f2": "abc", "f3": "f"},
+ {"f1": 2, "f2": 5, "f3": "xyz"}])
+ self.assertEqual(fileobj.getvalue(),
+ "f1,f2,f3\r\n1,abc,f\r\n2,5,xyz\r\n")
+
def test_write_no_fields(self):
fileobj = StringIO()
self.assertRaises(TypeError, csv.DictWriter, fileobj)
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -613,6 +613,7 @@
Rajagopalasarma Jayakrishnan
Zbigniew Jędrzejewski-Szmek
Julien Jehannet
+Muhammad Jehanzeb
Drew Jenkins
Flemming Kjær Jensen
Philip H. Jensen
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list