Lines Matching refs:fobj

108         with self.tar.extractfile(tarinfo) as fobj:
109 data = fobj.read()
121 with self.tar.extractfile(tarinfo) as fobj:
122 fobj2 = io.TextIOWrapper(fobj)
146 with open(os.path.join(TEMPDIR, "ustar/regtype"), "rb") as fobj:
147 data = fobj.read()
150 with self.tar.extractfile(tarinfo) as fobj:
151 text = fobj.read()
152 fobj.seek(0)
153 self.assertEqual(0, fobj.tell(),
155 fobj.seek(2048, 0)
156 self.assertEqual(2048, fobj.tell(),
158 fobj.seek(-1024, 1)
159 self.assertEqual(1024, fobj.tell(),
161 fobj.seek(1024, 1)
162 self.assertEqual(2048, fobj.tell(),
164 s = fobj.read(10)
167 fobj.seek(0, 2)
168 self.assertEqual(tarinfo.size, fobj.tell(),
170 self.assertEqual(fobj.read(), b"",
172 fobj.seek(-tarinfo.size, 2)
173 self.assertEqual(0, fobj.tell(),
175 fobj.seek(512)
176 s1 = fobj.readlines()
177 fobj.seek(512)
178 s2 = fobj.readlines()
181 fobj.seek(0)
182 self.assertEqual(len(fobj.readline()), fobj.tell(),
184 fobj.seek(512)
185 self.assertEqual(len(fobj.readline()) + 512, fobj.tell(),
187 fobj.seek(0)
188 line = fobj.readline()
189 self.assertEqual(fobj.read(), data[len(line):],
193 with self.tar.extractfile("ustar/regtype") as fobj:
194 fobj = io.TextIOWrapper(fobj)
195 data = fobj.read().encode("iso8859-1")
198 fobj.seek(100)
370 with open(tmpname, "rb") as fobj:
371 self.assertFalse(tarfile.is_tarfile(fobj))
384 with open(self.tarname, "rb") as fobj:
385 self.assertTrue(tarfile.is_tarfile(fobj))
388 with open(self.tarname, "rb") as fobj:
389 self.assertTrue(tarfile.is_tarfile(io.BytesIO(fobj.read())))
394 with open(self.tarname, "rb") as fobj:
395 tarfile.is_tarfile(fobj)
396 self.assertEqual(fobj.tell(), 0)
398 with open(self.tarname, "rb") as fobj:
399 file_like = io.BytesIO(fobj.read())
442 with self.open(tmpname, "w") as fobj:
443 fobj.write(char * 1024)
446 fobj.write(tarinfo.tobuf())
447 fobj.write(data)
464 with open(tmpname, "r+b") as fobj:
465 fobj.truncate(size)
494 with open(self.tarname, "rb") as fobj:
495 self.assertIsInstance(fobj.name, str)
496 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
498 self.assertEqual(tar.name, os.path.abspath(fobj.name))
501 with open(self.tarname, "rb") as fobj:
502 data = fobj.read()
503 fobj = io.BytesIO(data)
504 self.assertRaises(AttributeError, getattr, fobj, "name")
505 tar = tarfile.open(fileobj=fobj, mode=self.mode)
509 with open(self.tarname, "rb") as fobj:
510 data = fobj.read()
511 fobj = io.BytesIO(data)
512 fobj.name = ""
513 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
520 with open(fd, 'rb') as fobj:
521 self.assertIsInstance(fobj.name, int)
522 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
528 with open(tarname, 'rb') as fobj:
529 self.assertIsInstance(fobj.name, bytes)
530 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
532 self.assertEqual(tar.name, os.path.abspath(fobj.name))
575 with self.open(self.tarname) as fobj:
576 fobj.seek(offset)
579 with tar.open(self.tarname, mode="r:", fileobj=fobj) as tar:
591 with open(tarname, "rb") as fobj:
593 fileobj=fobj, mode=self.mode)
719 with open(empty, "wb") as fobj:
720 fobj.write(b"")
788 with self.tar.extractfile(tarinfo) as fobj:
791 buf = fobj.read(512)
800 with self.tar.extractfile(tarinfo) as fobj:
801 data = fobj.read()
898 with open(tarname, "rb") as fobj:
899 data = fobj.read()
902 with bz2.BZ2File(tmpname, "wb", compresslevel=1) as fobj:
903 fobj.write(data)
1034 fobj = io.BytesIO(self.tar.fileobj.read(3 * 512))
1036 tarfile.open(name="foo.tar", fileobj=fobj)
1043 with open(tarname, "rb") as fobj:
1044 fobj.seek(offset)
1045 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512),
1080 with open(filename, "rb") as fobj:
1081 data = fobj.read()
1112 with open(name, "wb") as fobj:
1114 fobj.seek(4096)
1115 fobj.write(b'x' * 4096)
1116 fobj.truncate()
1216 fobj = io.BytesIO()
1217 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
1219 self.assertFalse(fobj.closed, "external fileobjs must never closed")
1221 data = fobj.getvalue()
1224 self.assertFalse(fobj.closed)
1225 self.assertEqual(data, fobj.getvalue())
1237 with self.open(tmpname, "rb") as fobj:
1238 self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2)
1270 with open(path, "wb") as fobj:
1271 fobj.write(b"aaa")
1288 with open(path, "wb") as fobj:
1289 fobj.write(b"aaa")
1335 with open(path, "wb") as fobj:
1336 fobj.write(b"aaa")
1348 with open(target, "wb") as fobj:
1349 fobj.write(b"aaa")
1576 with open(tmpname, "rb") as fobj:
1577 data = fobj.read()
1581 with self.open(tmpname) as fobj:
1582 data = fobj.read()
1765 with open(cls.file_path, "wb") as fobj:
1766 fobj.write(b"aaa")
1887 with open(self.foo, "wb") as fobj:
1888 fobj.write(b"foo")
2300 fobj = io.BytesIO(b"\0" * 1024)
2301 self._add_testfile(fobj)
2302 fobj.seek(0)
2303 self._test(fileobj=fobj)
2307 with open(self.tarname, "rb") as fobj:
2308 data = fobj.read()
2309 fobj = io.BytesIO(data)
2310 self._add_testfile(fobj)
2311 fobj.seek(0)
2312 self._test(names=["foo", "bar"], fileobj=fobj)
2322 with open(self.tarname, "wb") as fobj:
2323 fobj.write(data)
2779 with open(tmpname, "wb") as fobj:
2781 with tarfile.open(fileobj=fobj, mode="w") as tar:
2785 self.assertFalse(fobj.closed, "external file object was closed")
2878 fobj = io.BytesIO(b"content")
2882 items = [(filename_1, 99, 98, tarfile.REGTYPE, fobj),
2884 (filename_2, 88, 87, tarfile.REGTYPE, fobj),
3895 with open(tarname, "rb") as fobj:
3896 data = fobj.read()