Lines Matching refs:fileobj
124 fileobj = os.fdopen(fd, "w+b")
126 writer = csv.writer(fileobj, **kwargs)
128 fileobj.seek(0)
129 self.assertEqual(fileobj.read(),
132 fileobj.close()
137 fileobj = os.fdopen(fd, "w+b")
139 writer = csv.writer(fileobj, **kwargs)
142 fileobj.seek(0)
143 self.assertEqual(fileobj.read(), '')
145 fileobj.close()
209 fileobj = os.fdopen(fd, "w+b")
211 writer = csv.writer(fileobj)
214 fileobj.seek(0)
215 self.assertEqual(fileobj.read(), "a,b\r\nc,d\r\n")
217 fileobj.close()
322 fileobj = os.fdopen(fd, "w+b")
324 writer = csv.writer(fileobj)
328 fileobj.seek(0)
329 for i, row in enumerate(csv.reader(fileobj)):
332 fileobj.close()
384 fileobj = os.fdopen(fd, "w+b")
386 fileobj.write("abc def\nc1ccccc1 benzene\n")
387 fileobj.seek(0)
388 rdr = csv.reader(fileobj, dialect=space())
392 fileobj.close()
406 fileobj = os.fdopen(fd, "w+b")
408 writer = csv.writer(fileobj)
410 fileobj.seek(0)
411 self.assertEqual(fileobj.read(), "1,2,3\r\n")
413 fileobj.close()
417 fileobj = os.fdopen(fd, "w+b")
419 writer = csv.writer(fileobj, testA)
421 fileobj.seek(0)
422 self.assertEqual(fileobj.read(), "1\t2\t3\r\n")
424 fileobj.close()
428 fileobj = os.fdopen(fd, "w+b")
430 writer = csv.writer(fileobj, dialect=testB())
432 fileobj.seek(0)
433 self.assertEqual(fileobj.read(), "1:2:3\r\n")
435 fileobj.close()
439 fileobj = os.fdopen(fd, "w+b")
441 writer = csv.writer(fileobj, dialect='testC')
443 fileobj.seek(0)
444 self.assertEqual(fileobj.read(), "1|2|3\r\n")
446 fileobj.close()
450 fileobj = os.fdopen(fd, "w+b")
452 writer = csv.writer(fileobj, dialect=testA, delimiter=';')
454 fileobj.seek(0)
455 self.assertEqual(fileobj.read(), "1;2;3\r\n")
457 fileobj.close()
486 fileobj = os.fdopen(fd, "w+b")
488 fileobj.write(input)
489 fileobj.seek(0)
490 reader = csv.reader(fileobj, dialect = self.dialect)
494 fileobj.close()
499 fileobj = os.fdopen(fd, "w+b")
501 writer = csv.writer(fileobj, dialect = self.dialect)
503 fileobj.seek(0)
504 self.assertEqual(fileobj.read(), expected_result)
506 fileobj.close()
637 fileobj = io.open(fd, 'w+b')
639 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
641 fileobj.seek(0)
642 self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n")
644 fileobj.seek(0)
645 fileobj.readline() # header
646 self.assertEqual(fileobj.read(), "10,,abc\r\n")
648 fileobj.close()
652 fileobj = StringIO()
653 self.assertRaises(TypeError, csv.DictWriter, fileobj)
657 fileobj = os.fdopen(fd, "w+b")
659 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
669 fileobj.close()
674 fileobj = os.fdopen(fd, "w+b")
676 fileobj.write("1,2,abc\r\n")
677 fileobj.seek(0)
678 reader = csv.DictReader(fileobj,
682 fileobj.close()
687 fileobj = os.fdopen(fd, "w+b")
689 fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
690 fileobj.seek(0)
691 reader = csv.DictReader(fileobj)
695 fileobj.close()
731 fileobj = os.fdopen(fd, "w+b")
733 fileobj.write("1,2,abc,4,5,6\r\n")
734 fileobj.seek(0)
735 reader = csv.DictReader(fileobj,
740 fileobj.close()
745 fileobj = os.fdopen(fd, "w+b")
747 fileobj.write("1,2,abc,4,5,6\r\n")
748 fileobj.seek(0)
749 reader = csv.DictReader(fileobj,
754 fileobj.close()
759 fileobj = os.fdopen(fd, "w+b")
761 fileobj.write("f1,f2\r\n1,2,abc,4,5,6\r\n")
762 fileobj.seek(0)
763 reader = csv.DictReader(fileobj, restkey="_rest")
768 fileobj.close()
773 fileobj = os.fdopen(fd, "w+b")
775 fileobj.write("1,2,abc,4,5,6\r\n1,2,abc\r\n")
776 fileobj.seek(0)
777 reader = csv.DictReader(fileobj,
786 fileobj.close()
827 fileobj = os.fdopen(fd, "w+b")
829 writer = csv.writer(fileobj, dialect="excel")
832 fileobj.seek(0)
833 self.assertEqual(fileobj.read(), expected)
835 fileobj.close()
843 fileobj = os.fdopen(fd, "w+b")
845 writer = csv.writer(fileobj, dialect="excel")
848 fileobj.seek(0)
849 self.assertEqual(fileobj.read(), expected)
851 fileobj.close()
859 fileobj = os.fdopen(fd, "w+b")
861 writer = csv.writer(fileobj, dialect="excel")
864 fileobj.seek(0)
865 self.assertEqual(fileobj.read(), expected)
867 fileobj.close()
874 fileobj = os.fdopen(fd, "w+b")
876 writer = csv.writer(fileobj, dialect="excel")
879 fileobj.seek(0)
880 self.assertEqual(fileobj.read(), expected)
882 fileobj.close()