• Home
  • Raw
  • Download

Lines Matching refs:fileobj

123         with TemporaryFile("w+", newline='') as fileobj:
124 writer = csv.writer(fileobj, **kwargs)
126 fileobj.seek(0)
127 self.assertEqual(fileobj.read(),
131 with TemporaryFile("w+", newline='') as fileobj:
132 writer = csv.writer(fileobj, **kwargs)
135 fileobj.seek(0)
136 self.assertEqual(fileobj.read(), '')
207 with TemporaryFile("w+", newline='') as fileobj:
208 writer = csv.writer(fileobj)
211 fileobj.seek(0)
212 self.assertEqual(fileobj.read(), "a,b\r\nc,d\r\n")
215 with TemporaryFile("w+", newline='') as fileobj:
216 writer = csv.writer(fileobj)
218 fileobj.seek(0)
219 self.assertEqual(fileobj.read(), "a,\r\n,d\r\n")
221 with TemporaryFile("w+", newline='') as fileobj:
222 writer = csv.writer(fileobj)
224 fileobj.seek(0)
225 self.assertEqual(fileobj.read(), '""\r\na\r\n')
227 with TemporaryFile("w+", newline='') as fileobj:
228 writer = csv.writer(fileobj)
230 fileobj.seek(0)
231 self.assertEqual(fileobj.read(), 'a\r\n""\r\n')
238 with TemporaryFile("w+", newline='') as fileobj:
239 writer = csv.writer(fileobj)
241 fileobj.seek(0)
242 self.assertEqual(fileobj.read(), "a\r\n")
335 with TemporaryFile("w+", newline='') as fileobj:
336 writer = csv.writer(fileobj)
340 fileobj.seek(0)
341 for i, row in enumerate(csv.reader(fileobj)):
345 with TemporaryFile("w+", newline='') as fileobj:
346 writer = csv.writer(fileobj,quoting=csv.QUOTE_NONE,escapechar="\\")
349 fileobj.seek(0)
350 for i, row in enumerate(csv.reader(fileobj,quoting=csv.QUOTE_NONE,escapechar="\\")):
401 with TemporaryFile("w+") as fileobj:
402 fileobj.write("abc def\nc1ccccc1 benzene\n")
403 fileobj.seek(0)
404 reader = csv.reader(fileobj, dialect=space())
410 with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
412 writer = csv.writer(fileobj, *writeargs, **kwwriteargs)
414 fileobj.seek(0)
415 self.assertEqual(fileobj.read(), expected)
462 with TemporaryFile("w+", newline='') as fileobj:
463 fileobj.write(input)
464 fileobj.seek(0)
465 reader = csv.reader(fileobj, dialect = self.dialect)
470 with TemporaryFile("w+", newline='') as fileobj:
471 writer = csv.writer(fileobj, dialect = self.dialect)
473 fileobj.seek(0)
474 self.assertEqual(fileobj.read(), expected_result)
612 with TemporaryFile("w+", newline='') as fileobj:
613 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
615 fileobj.seek(0)
616 self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n")
618 fileobj.seek(0)
619 fileobj.readline() # header
620 self.assertEqual(fileobj.read(), "10,,abc\r\n")
623 fileobj = StringIO()
624 writer = csv.DictWriter(fileobj, fieldnames=["f1", "f2", "f3"])
626 self.assertEqual(fileobj.getvalue(), "f1,f2,f3\r\n")
629 self.assertEqual(fileobj.getvalue(),
633 fileobj = StringIO()
634 self.assertRaises(TypeError, csv.DictWriter, fileobj)
637 with TemporaryFile("w+", newline='') as fileobj:
638 writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
649 fileobj = StringIO()
650 self.assertRaises(ValueError, csv.DictWriter, fileobj, ['f1', 'f2'],
654 fileobj = StringIO()
655 writer = csv.DictWriter(fileobj, ['f1', 'f2'], extrasaction="raise")
660 fileobj = StringIO()
661 writer = csv.DictWriter(fileobj, ['f1', 'f2'], extrasaction="ignore")
664 self.assertEqual(fileobj.getvalue(), "1,2\r\n")
667 with TemporaryFile("w+") as fileobj:
668 fileobj.write("1,2,abc\r\n")
669 fileobj.seek(0)
670 reader = csv.DictReader(fileobj,
675 with TemporaryFile("w+") as fileobj:
676 fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
677 fileobj.seek(0)
678 reader = csv.DictReader(fileobj)
685 with TemporaryFile("w+") as fileobj:
686 fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
687 fileobj.seek(0)
688 reader = csv.DictReader(fileobj,
689 fieldnames=next(csv.reader(fileobj)))
695 with TemporaryFile("w+") as fileobj:
696 fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
697 fileobj.seek(0)
698 reader = csv.DictReader(fileobj)
705 with TemporaryFile("w+") as fileobj:
706 fileobj.write("1,2,abc,4,5,6\r\n")
707 fileobj.seek(0)
708 reader = csv.DictReader(fileobj,
714 with TemporaryFile("w+") as fileobj:
715 fileobj.write("1,2,abc,4,5,6\r\n")
716 fileobj.seek(0)
717 reader = csv.DictReader(fileobj,
723 with TemporaryFile("w+") as fileobj:
724 fileobj.write("f1,f2\r\n1,2,abc,4,5,6\r\n")
725 fileobj.seek(0)
726 reader = csv.DictReader(fileobj, restkey="_rest")
732 with TemporaryFile("w+") as fileobj:
733 fileobj.write("1,2,abc,4,5,6\r\n1,2,abc\r\n")
734 fileobj.seek(0)
735 reader = csv.DictReader(fileobj,
781 with TemporaryFile("w+", newline='') as fileobj:
782 writer = csv.writer(fileobj, dialect="excel")
785 fileobj.seek(0)
786 self.assertEqual(fileobj.read(), expected)
792 with TemporaryFile("w+", newline='') as fileobj:
793 writer = csv.writer(fileobj, dialect="excel")
796 fileobj.seek(0)
797 self.assertEqual(fileobj.read(), expected)
803 with TemporaryFile("w+", newline='') as fileobj:
804 writer = csv.writer(fileobj, dialect="excel")
807 fileobj.seek(0)
808 self.assertEqual(fileobj.read(), expected)
814 with TemporaryFile("w+", newline='') as fileobj:
815 writer = csv.writer(fileobj, dialect="excel")
818 fileobj.seek(0)
819 self.assertEqual(fileobj.read(), expected)
1130 with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
1131 fileobj.write(",".join(self.names) + "\r\n")
1132 fileobj.seek(0)
1133 reader = csv.reader(fileobj)
1138 with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
1139 writer = csv.writer(fileobj)
1142 fileobj.seek(0)
1143 self.assertEqual(fileobj.read(), expected)