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()
312 fileobj = os.fdopen(fd, "w+b")
314 writer = csv.writer(fileobj)
318 fileobj.seek(0)
319 for i, row in enumerate(csv.reader(fileobj)):
322 fileobj.close()
374 fileobj = os.fdopen(fd, "w+b")
376 fileobj.write("abc def\nc1ccccc1 benzene\n")
377 fileobj.seek(0)
378 rdr = csv.reader(fileobj, dialect=space())
382 fileobj.close()
396 fileobj = os.fdopen(fd, "w+b")
398 writer = csv.writer(fileobj)
400 fileobj.seek(0)
401 self.assertEqual(fileobj.read(), "1,2,3\r\n")
403 fileobj.close()
407 fileobj = os.fdopen(fd, "w+b")
409 writer = csv.writer(fileobj, testA)
411 fileobj.seek(0)
412 self.assertEqual(fileobj.read(), "1\t2\t3\r\n")
414 fileobj.close()
418 fileobj = os.fdopen(fd, "w+b")
420 writer = csv.writer(fileobj, dialect=testB())
422 fileobj.seek(0)
423 self.assertEqual(fileobj.read(), "1:2:3\r\n")
425 fileobj.close()
429 fileobj = os.fdopen(fd, "w+b")
431 writer = csv.writer(fileobj, dialect='testC')
433 fileobj.seek(0)
434 self.assertEqual(fileobj.read(), "1|2|3\r\n")
436 fileobj.close()
440 fileobj = os.fdopen(fd, "w+b")
442 writer = csv.writer(fileobj, dialect=testA, delimiter=';')
444 fileobj.seek(0)
445 self.assertEqual(fileobj.read(), "1;2;3\r\n")
447 fileobj.close()
464 fileobj = os.fdopen(fd, "w+b")
466 fileobj.write(input)
467 fileobj.seek(0)
468 reader = csv.reader(fileobj, dialect = self.dialect)
472 fileobj.close()
477 fileobj = os.fdopen(fd, "w+b")
479 writer = csv.writer(fileobj, dialect = self.dialect)
481 fileobj.seek(0)
482 self.assertEqual(fileobj.read(), expected_result)
484 fileobj.close()
615 fileobj = io.open(fd, 'w+b')
617 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
619 fileobj.seek(0)
620 self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n")
622 fileobj.seek(0)
623 fileobj.readline() # header
624 self.assertEqual(fileobj.read(), "10,,abc\r\n")
626 fileobj.close()
630 fileobj = StringIO()
631 self.assertRaises(TypeError, csv.DictWriter, fileobj)
635 fileobj = os.fdopen(fd, "w+b")
637 fileobj.write("1,2,abc\r\n")
638 fileobj.seek(0)
639 reader = csv.DictReader(fileobj,
643 fileobj.close()
648 fileobj = os.fdopen(fd, "w+b")
650 fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
651 fileobj.seek(0)
652 reader = csv.DictReader(fileobj)
656 fileobj.close()
692 fileobj = os.fdopen(fd, "w+b")
694 fileobj.write("1,2,abc,4,5,6\r\n")
695 fileobj.seek(0)
696 reader = csv.DictReader(fileobj,
701 fileobj.close()
706 fileobj = os.fdopen(fd, "w+b")
708 fileobj.write("1,2,abc,4,5,6\r\n")
709 fileobj.seek(0)
710 reader = csv.DictReader(fileobj,
715 fileobj.close()
720 fileobj = os.fdopen(fd, "w+b")
722 fileobj.write("f1,f2\r\n1,2,abc,4,5,6\r\n")
723 fileobj.seek(0)
724 reader = csv.DictReader(fileobj, restkey="_rest")
729 fileobj.close()
734 fileobj = os.fdopen(fd, "w+b")
736 fileobj.write("1,2,abc,4,5,6\r\n1,2,abc\r\n")
737 fileobj.seek(0)
738 reader = csv.DictReader(fileobj,
747 fileobj.close()
788 fileobj = os.fdopen(fd, "w+b")
790 writer = csv.writer(fileobj, dialect="excel")
793 fileobj.seek(0)
794 self.assertEqual(fileobj.read(), expected)
796 fileobj.close()
804 fileobj = os.fdopen(fd, "w+b")
806 writer = csv.writer(fileobj, dialect="excel")
809 fileobj.seek(0)
810 self.assertEqual(fileobj.read(), expected)
812 fileobj.close()
820 fileobj = os.fdopen(fd, "w+b")
822 writer = csv.writer(fileobj, dialect="excel")
825 fileobj.seek(0)
826 self.assertEqual(fileobj.read(), expected)
828 fileobj.close()
835 fileobj = os.fdopen(fd, "w+b")
837 writer = csv.writer(fileobj, dialect="excel")
840 fileobj.seek(0)
841 self.assertEqual(fileobj.read(), expected)
843 fileobj.close()