Lines Matching refs:fileobj
122 fileobj = os.fdopen(fd, "w+b")
124 writer = csv.writer(fileobj, **kwargs)
126 fileobj.seek(0)
127 self.assertEqual(fileobj.read(),
130 fileobj.close()
199 fileobj = os.fdopen(fd, "w+b")
201 writer = csv.writer(fileobj)
204 fileobj.seek(0)
205 self.assertEqual(fileobj.read(), "a,b\r\nc,d\r\n")
207 fileobj.close()
291 fileobj = os.fdopen(fd, "w+b")
293 writer = csv.writer(fileobj)
297 fileobj.seek(0)
298 for i, row in enumerate(csv.reader(fileobj)):
301 fileobj.close()
353 fileobj = os.fdopen(fd, "w+b")
355 fileobj.write("abc def\nc1ccccc1 benzene\n")
356 fileobj.seek(0)
357 rdr = csv.reader(fileobj, dialect=space())
361 fileobj.close()
375 fileobj = os.fdopen(fd, "w+b")
377 writer = csv.writer(fileobj)
379 fileobj.seek(0)
380 self.assertEqual(fileobj.read(), "1,2,3\r\n")
382 fileobj.close()
386 fileobj
388 writer = csv.writer(fileobj, testA)
390 fileobj.seek(0)
391 self.assertEqual(fileobj.read(), "1\t2\t3\r\n")
393 fileobj.close()
397 fileobj = os.fdopen(fd, "w+b")
399 writer = csv.writer(fileobj, dialect=testB())
401 fileobj.seek(0)
402 self.assertEqual(fileobj.read(), "1:2:3\r\n")
404 fileobj.close()
408 fileobj = os.fdopen(fd, "w+b")
410 writer = csv.writer(fileobj, dialect='testC')
412 fileobj.seek(0)
413 self.assertEqual(fileobj.read(), "1|2|3\r\n")
415 fileobj.close()
419 fileobj = os.fdopen(fd, "w+b")
421 writer = csv.writer(fileobj, dialect=testA, delimiter=';')
423 fileobj.seek(0)
424 self.assertEqual(fileobj.read(), "1;2;3\r\n")
426 fileobj.close()
443 fileobj = os.fdopen(fd, "w+b")
445 fileobj.write(input)
446 fileobj.seek(0)
447 reader = csv.reader(fileobj, dialect = self.dialect)
451 fileobj.close()
456 fileobj = os.fdopen(fd, "w+b")
458 writer = csv.writer(fileobj, dialect = self.dialect)
460 fileobj.seek(0)
461 self.assertEqual(fileobj.read(), expected_result)
463 fileobj.close()
594 fileobj = io.open(fd, 'w+b')
596 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
598 fileobj.seek(0)
599 self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n")
601 fileobj.seek(0)
602 fileobj.readline() # header
603 self.assertEqual(fileobj.read(), "10,,abc\r\n")
605 fileobj.close()
609 fileobj = StringIO()
610 self.assertRaises(TypeError, csv.DictWriter, fileobj)
614 fileobj = os.fdopen(fd, "w+b")
616 fileobj.write("1,2,abc\r\n")
617 fileobj.seek(0)
618 reader = csv.DictReader(fileobj,
622 fileobj.close()
627 fileobj = os.fdopen(fd, "w+b")
629 fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
630 fileobj.seek(0)
631 reader = csv.DictReader(fileobj)
635 fileobj.close()
671 fileobj = os.fdopen(fd, "w+b")
673 fileobj.write("1,2,abc,4,5,6\r\n")
674 fileobj.seek(0)
675 reader = csv.DictReader(fileobj,
680 fileobj.close()
685 fileobj = os.fdopen(fd, "w+b")
687 fileobj.write("1,2,abc,4,5,6\r\n")
688 fileobj.seek(0)
689 reader = csv.DictReader(fileobj,
694 fileobj.close()
699 fileobj = os.fdopen(fd, "w+b")
701 fileobj.write("f1,f2\r\n1,2,abc,4,5,6\r\n")
702 fileobj.seek(0)
703 reader = csv.DictReader(fileobj, restkey="_rest")
708 fileobj.close()
713 fileobj = os.fdopen(fd, "w+b")
715 fileobj.write("1,2,abc,4,5,6\r\n1,2,abc\r\n")
716 fileobj.seek(0)
717 reader = csv.DictReader(fileobj,
726 fileobj.close()
767 fileobj = os.fdopen(fd, "w+b")
769 writer = csv.writer(fileobj, dialect="excel")
772 fileobj.seek(0)
773 self.assertEqual(fileobj.read(), expected)
775 fileobj.close()
783 fileobj = os.fdopen(fd, "w+b")
785 writer = csv.writer(fileobj, dialect="excel")
788 fileobj.seek(0)
789 self.assertEqual(fileobj.read(), expected)
791 fileobj.close()
799 fileobj = os.fdopen(fd, "w+b")
801 writer = csv.writer(fileobj, dialect="excel")
804 fileobj.seek(0)
805 self.assertEqual(fileobj.read(), expected)
807 fileobj.close()
814 fileobj = os.fdopen(fd, "w+b")
816 writer = csv.writer(fileobj, dialect="excel")
819 fileobj.seek(0)
820 self.assertEqual(fileobj.read(), expected)
822 fileobj.close()