mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
bpo-27497: Add return value to csv.DictWriter.writeheader (GH-12306)
csv.DictWriter.writeheader() now returns the return value of the underlying csv.Writer.writerow() method. Patch contributed by Ashish Nitin Patil.
This commit is contained in:
parent
d237b3f0f6
commit
fce5ff1e18
4 changed files with 18 additions and 3 deletions
|
@ -608,6 +608,12 @@ class TestQuotedEscapedExcel(TestCsvBase):
|
|||
class TestDictFields(unittest.TestCase):
|
||||
### "long" means the row is longer than the number of fieldnames
|
||||
### "short" means there are fewer elements in the row than fieldnames
|
||||
def test_writeheader_return_value(self):
|
||||
with TemporaryFile("w+", newline='') as fileobj:
|
||||
writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
|
||||
writeheader_return_value = writer.writeheader()
|
||||
self.assertEqual(writeheader_return_value, 10)
|
||||
|
||||
def test_write_simple_dict(self):
|
||||
with TemporaryFile("w+", newline='') as fileobj:
|
||||
writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue