(self)
| 869 | self.assertRaises(TypeError, csv.DictWriter, fileobj) |
| 870 | |
| 871 | def test_write_fields_not_in_fieldnames(self): |
| 872 | with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj: |
| 873 | writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"]) |
| 874 | # Of special note is the non-string key (issue 19449) |
| 875 | with self.assertRaises(ValueError) as cx: |
| 876 | writer.writerow({"f4": 10, "f2": "spam", 1: "abc"}) |
| 877 | exception = str(cx.exception) |
| 878 | self.assertIn("fieldnames", exception) |
| 879 | self.assertIn("'f4'", exception) |
| 880 | self.assertNotIn("'f2'", exception) |
| 881 | self.assertIn("1", exception) |
| 882 | |
| 883 | def test_typo_in_extrasaction_raises_error(self): |
| 884 | fileobj = StringIO() |
nothing calls this directly
no test coverage detected