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

Method test_writerows_with_none

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

Source from the content-addressed store, hash-verified

295 self.assertEqual(fileobj.read(), "a,b\r\nc,d\r\n")
296
297 def test_writerows_with_none(self):
298 with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:
299 writer = csv.writer(fileobj)
300 writer.writerows([['a', None], [None, 'd']])
301 fileobj.seek(0)
302 self.assertEqual(fileobj.read(), "a,\r\n,d\r\n")
303
304 with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:
305 writer = csv.writer(fileobj)
306 writer.writerows([[None], ['a']])
307 fileobj.seek(0)
308 self.assertEqual(fileobj.read(), '""\r\na\r\n')
309
310 with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:
311 writer = csv.writer(fileobj)
312 writer.writerows([['a'], [None]])
313 fileobj.seek(0)
314 self.assertEqual(fileobj.read(), 'a\r\n""\r\n')
315
316
317 def test_write_empty_fields(self):

Callers

nothing calls this directly

Calls 6

TemporaryFileFunction · 0.90
writerowsMethod · 0.80
writerMethod · 0.45
seekMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected