MCPcopy Index your code
hub / github.com/python/cpython / test_write_multiple_dict_rows

Method test_write_multiple_dict_rows

Lib/test/test_csv.py:857–865  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

855 self.assertEqual(fileobj.read(), "10,,abc\r\n")
856
857 def test_write_multiple_dict_rows(self):
858 fileobj = StringIO()
859 writer = csv.DictWriter(fileobj, fieldnames=["f1", "f2", "f3"])
860 writer.writeheader()
861 self.assertEqual(fileobj.getvalue(), "f1,f2,f3\r\n")
862 writer.writerows([{"f1": 1, "f2": "abc", "f3": "f"},
863 {"f1": 2, "f2": 5, "f3": "xyz"}])
864 self.assertEqual(fileobj.getvalue(),
865 "f1,f2,f3\r\n1,abc,f\r\n2,5,xyz\r\n")
866
867 def test_write_no_fields(self):
868 fileobj = StringIO()

Callers

nothing calls this directly

Calls 5

writeheaderMethod · 0.95
getvalueMethod · 0.95
writerowsMethod · 0.95
StringIOClass · 0.90
assertEqualMethod · 0.45

Tested by

no test coverage detected