merge heads

This commit is contained in:
Giampaolo Rodola' 2014-04-29 02:04:14 +02:00
commit 7971286b6e
2 changed files with 11 additions and 0 deletions

View File

@ -575,6 +575,16 @@ class TestDictFields(unittest.TestCase):
fileobj.readline() # header fileobj.readline() # header
self.assertEqual(fileobj.read(), "10,,abc\r\n") 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): def test_write_no_fields(self):
fileobj = StringIO() fileobj = StringIO()
self.assertRaises(TypeError, csv.DictWriter, fileobj) self.assertRaises(TypeError, csv.DictWriter, fileobj)

View File

@ -613,6 +613,7 @@ Juhana Jauhiainen
Rajagopalasarma Jayakrishnan Rajagopalasarma Jayakrishnan
Zbigniew Jędrzejewski-Szmek Zbigniew Jędrzejewski-Szmek
Julien Jehannet Julien Jehannet
Muhammad Jehanzeb
Drew Jenkins Drew Jenkins
Flemming Kjær Jensen Flemming Kjær Jensen
Philip H. Jensen Philip H. Jensen