def test_int_write(self):
import array
contents = [(20-i) for i in range(20)]
a = array.array('i', contents)
fd, name = tempfile.mkstemp()
fileobj = os.fdopen(fd, "w+b")
try:
writer = csv.writer(fileobj, dialect="excel")
writer.writerow(a)
expected = ",".join([str(i) for i in a])+"\r\n"
fileobj.seek(0)
self.assertEqual(fileobj.read(), expected)
finally:
fileobj.close()
os.unlink(name)
评论列表
文章目录