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

Method test_write_simple_dict

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

Source from the content-addressed store, hash-verified

844 self.assertEqual(writeheader_return_value, 10)
845
846 def test_write_simple_dict(self):
847 with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:
848 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
849 writer.writeheader()
850 fileobj.seek(0)
851 self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n")
852 writer.writerow({"f1": 10, "f3": "abc"})
853 fileobj.seek(0)
854 fileobj.readline() # header
855 self.assertEqual(fileobj.read(), "10,,abc\r\n")
856
857 def test_write_multiple_dict_rows(self):
858 fileobj = StringIO()

Callers

nothing calls this directly

Calls 7

writeheaderMethod · 0.95
writerowMethod · 0.95
TemporaryFileFunction · 0.90
seekMethod · 0.45
assertEqualMethod · 0.45
readlineMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected