Lines Matching refs:fobj
56 fobj = self.tar.extractfile(tarinfo)
57 data = fobj.read()
90 with open(os.path.join(TEMPDIR, "ustar/regtype"), "rb") as fobj:
91 data = fobj.read()
94 fobj = self.tar.extractfile(tarinfo)
96 text = fobj.read()
97 fobj.seek(0)
98 self.assertTrue(0 == fobj.tell(),
100 fobj.seek(2048, 0)
101 self.assertTrue(2048 == fobj.tell(),
103 fobj.seek(-1024, 1)
104 self.assertTrue(1024 == fobj.tell(),
106 fobj.seek(1024, 1)
107 self.assertTrue(2048 == fobj.tell(),
109 s = fobj.read(10)
112 fobj.seek(0, 2)
113 self.assertTrue(tarinfo.size == fobj.tell(),
115 self.assertTrue(fobj.read() == "",
117 fobj.seek(-tarinfo.size, 2)
118 self.assertTrue(0 == fobj.tell(),
120 fobj.seek(512)
121 s1 = fobj.readlines()
122 fobj.seek(512)
123 s2 = fobj.readlines()
126 fobj.seek(0)
127 self.assertTrue(len(fobj.readline()) == fobj.tell(),
129 fobj.seek(512)
130 self.assertTrue(len(fobj.readline()) + 512 == fobj.tell(),
132 fobj.seek(0)
133 line = fobj.readline()
134 self.assertTrue(fobj.read() == data[len(line):],
136 fobj.close()
286 with _open(tmpname, "wb") as fobj:
287 fobj.write(char * 1024)
290 fobj.write(tarinfo.tobuf())
291 fobj.write(data)
307 with open(tmpname, "r+b") as fobj:
308 fobj.truncate(size)
329 with open(self.tarname, "rb") as fobj:
330 tar = tarfile.open(fileobj=fobj, mode=self.mode)
331 self.assertEqual(tar.name, os.path.abspath(fobj.name))
334 with open(self.tarname, "rb") as fobj:
335 data = fobj.read()
336 fobj = StringIO.StringIO(data)
337 self.assertRaises(AttributeError, getattr, fobj, "name")
338 tar = tarfile.open(fileobj=fobj, mode=self.mode)
342 with open(self.tarname, "rb") as fobj:
343 data = fobj.read()
344 fobj = StringIO.StringIO(data)
345 fobj.name = ""
346 tar = tarfile.open(fileobj=fobj, mode=self.mode)
380 fobj = _open(self.tarname, "rb")
382 fobj.seek(offset)
385 tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
395 fobj.close()
402 with open(tarname, "rb") as fobj:
404 fileobj=fobj, mode=self.mode)
475 with open(empty, "wb") as fobj:
476 fobj.write("")
504 fobj = self.tar.extractfile(tarinfo)
505 data = fobj.read()
601 with open(tarname, "rb") as fobj:
602 data = fobj.read()
605 with bz2.BZ2File(tmpname, "wb", compresslevel=1) as fobj:
606 fobj.write(data)
712 fobj = StringIO.StringIO(self.tar.fileobj.read(3 * 512))
713 self.assertRaises(tarfile.ReadError, tarfile.open, name="foo.tar", fileobj=fobj)
720 fobj = open(tarname)
721 fobj.seek(offset)
722 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512))
787 fobj = StringIO.StringIO()
788 tar = tarfile.open(fileobj=fobj, mode=self.mode)
791 self.assertTrue(fobj.closed is False, "external fileobjs must never closed")
793 data = fobj.getvalue()
796 self.assertFalse(fobj.closed)
797 self.assertEqual(data, fobj.getvalue())
829 with open(path, "wb") as fobj:
830 fobj.write("aaa")
848 with open(path, "wb") as fobj:
849 fobj.write("aaa")
872 with open(target, "wb") as fobj:
873 fobj.write("aaa")
1165 with gzip.GzipFile(tmpname) as fobj:
1166 data = fobj.read()
1169 with open(tmpname, "rb") as fobj:
1170 data = fobj.read()
1175 with open(tmpname, "rb") as fobj:
1176 data = fobj.read()
1297 with open(self.foo, "wb") as fobj:
1298 fobj.write("foo")
1479 fobj = StringIO.StringIO()
1480 … tar = tarfile.open("foo.tar", mode="w", fileobj=fobj, format=self.format, encoding="iso8859-1")
1485 fobj.seek(0)
1487 tar = tarfile.open("foo.tar", fileobj=fobj, encoding="iso8859-1")
1567 fobj = StringIO.StringIO("\0" * 1024)
1568 self._add_testfile(fobj)
1569 fobj.seek(0)
1570 self._test(fileobj=fobj)
1574 with open(self.tarname) as fobj:
1575 data = fobj.read()
1576 fobj = StringIO.StringIO(data)
1577 self._add_testfile(fobj)
1578 fobj.seek(0)
1579 self._test(names=["foo", "bar"], fileobj=fobj)
1599 with open(self.tarname, "wb") as fobj:
1600 fobj.write(data)
1736 with open(tmpname, "wb") as fobj:
1738 with tarfile.open(fileobj=fobj, mode="w") as tar:
1742 self.assertFalse(fobj.closed, "external file object was closed")
1861 with open(tarname, "rb") as fobj:
1862 data = fobj.read()