Home | History | Annotate | Download | only in test

Lines Matching refs:zipfp

55         with zipfile.ZipFile(f, "w", compression) as zipfp:
56 zipfp.write(TESTFN, "another.name")
57 zipfp.write(TESTFN, TESTFN)
58 zipfp.writestr("strfile", self.data)
64 with zipfile.ZipFile(f, "r", compression) as zipfp:
65 self.assertEqual(zipfp.read(TESTFN), self.data)
66 self.assertEqual(zipfp.read("another.name"), self.data)
67 self.assertEqual(zipfp.read("strfile"), self.data)
74 zipfp.printdir()
93 names = zipfp.namelist()
100 infos = zipfp.infolist()
111 info = zipfp.getinfo(nm)
116 zipfp.testzip()
126 with zipfile.ZipFile(f, "r", compression) as zipfp:
128 with zipfp.open(TESTFN) as zipopen1:
136 with zipfp.open("another.name") as zipopen2:
152 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
153 zipfp.writestr("name", "foo")
155 zipfp.writestr("name", "bar")
156 self.assertEqual(zipfp.namelist(), ["name"] * 2)
158 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
159 infos = zipfp.infolist()
162 with zipfp.open(info) as f:
167 data += zipfp.read(info)
174 with zipfile.ZipFile(f, "r", compression) as zipfp:
176 with zipfp.open(TESTFN) as zipopen1:
193 with zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED) as zipfp:
194 zipfp.writestr(TESTFN, data)
197 with zipfile.ZipFile(f, 'r') as zipfp:
198 with zipfp.open(TESTFN, 'rU') as zipopen:
208 with zipfile.ZipFile(f, "r") as zipfp:
209 with zipfp.open(TESTFN) as zipopen:
228 with zipfile.ZipFile(f, "r") as zipfp:
229 with zipfp.open(TESTFN) as zipopen:
238 with zipfile.ZipFile(f, "r") as zipfp:
239 with zipfp.open(TESTFN) as zo:
248 with zipfile.ZipFile(f, "r") as zipfp:
249 for line, zipline in zip(self.line_gen, zipfp.open(TESTFN)):
309 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp:
310 zipfp.writestr("strfile", '12')
313 with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_DEFLATED) as zipfp:
314 with zipfp.open("strfile") as openobj:
319 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
320 zipfp.write(TESTFN, "/absolute")
322 with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:
323 self.assertEqual(zipfp.namelist(), ["absolute"])
327 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
328 zipfp.write(TESTFN, TESTFN)
330 with zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED) as zipfp:
331 zipfp.writestr("strfile", self.data)
332 self.assertEqual(zipfp.namelist(), [TESTFN, "strfile"])
342 with zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED) as zipfp:
343 zipfp.write(TESTFN, TESTFN)
347 with zipfile.ZipFile(f, "r") as zipfp:
348 self.assertEqual(zipfp.namelist(), [TESTFN])
349 self.assertEqual(zipfp.read(TESTFN), self.data)
353 with io.BytesIO(zipfiledata) as bio, zipfile.ZipFile(bio) as zipfp:
354 self.assertEqual(zipfp.namelist(), [TESTFN])
355 self.assertEqual(zipfp.read(TESTFN), self.data)
359 with zipfile.ZipFile(bio, 'w', zipfile.ZIP_STORED) as zipfp:
360 zipfp.write(TESTFN, TESTFN)
367 with zipfile.ZipFile(TESTFN2) as zipfp:
368 self.assertEqual(zipfp.namelist(), [TESTFN])
369 self.assertEqual(zipfp.read(TESTFN), self.data)
373 with zipfile.ZipFile(bio, 'w', zipfile.ZIP_STORED) as zipfp:
374 zipfp.write(TESTFN, TESTFN)
381 with zipfile.ZipFile(TESTFN2, 'a') as zipfp:
382 self.assertEqual(zipfp.namelist(), [TESTFN])
383 zipfp.writestr('strfile', self.data)
388 with io.BytesIO(zipfiledata) as bio, zipfile.ZipFile(bio) as zipfp:
389 self.assertEqual(zipfp.namelist(), [TESTFN, 'strfile'])
390 self.assertEqual(zipfp.read(TESTFN), self.data)
391 self.assertEqual(zipfp.read('strfile'), self.data)
394 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
395 zipfp.write(TESTFN, TESTFN)
398 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
399 self.assertIsInstance(zipfp, zipfile.ZipFile)
402 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
403 zipfp.comment = b"this is a comment"
404 zipfp.write(TESTFN, TESTFN)
407 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
408 self.assertIsInstance(zipfp, zipfile.ZipFile)
409 self.assertEqual(zipfp.comment, b"this is a comment")
414 with zipfile.ZipFile(TESTFN2, "w") as zipfp:
415 zipfp.write(TESTFN)
417 self.assertEqual(zipfp.read(TESTFN), fid.read())
423 with zipfile.ZipFile(TESTFN2, "w") as zipfp:
424 zipfp.write(TESTFN, 'storeme', zipfile.ZIP_STORED)
425 zipfp.write(TESTFN, 'deflateme', zipfile.ZIP_DEFLATED)
426 sinfo = zipfp.getinfo('storeme')
427 dinfo = zipfp.getinfo('deflateme')
434 with zipfile.ZipFile(TESTFN2, mode="w") as zipfp:
435 zipfp.writestr("somefile.txt", "bogus")
437 with zipfile.ZipFile(TESTFN2, mode="r") as zipfp:
438 self.assertRaises(RuntimeError, zipfp.write, TESTFN)
441 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
443 zipfp.writestr(fpath, fdata)
445 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
447 writtenfile = zipfp.extract(fpath)
464 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
466 zipfp.writestr(fpath, fdata)
468 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
469 zipfp.extractall()
489 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
491 zipfp.writestr(fname, content)
493 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
495 writtenfile = zipfp.extract(fname)
547 with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_STORED) as zipfp:
552 zipfp.writestr(zinfo, content)
558 with zipfile.ZipFile(TESTFN2, 'r') as zipfp:
559 writtenfile = zipfp.extract(arcname, targetpath)
565 with zipfile.ZipFile(TESTFN2, 'r') as zipfp:
566 zipfp.extractall(targetpath)
572 with zipfile.ZipFile(TESTFN2, 'r') as zipfp:
573 writtenfile = zipfp.extract(arcname)
579 with zipfile.ZipFile(TESTFN2, 'r') as zipfp:
580 zipfp.extractall()
587 zipfp = zipfile.ZipFile(TESTFN2, "w")
588 zipfp.writestr("a.txt", "hello world", compress_type=zipfile.ZIP_STORED)
590 zipfp.writestr("b.txt", "hello world", compress_type=zipfile.ZIP_DEFLATED)
592 info = zipfp.getinfo('a.txt')
596 info = zipfp.getinfo('b.txt')
605 with zipfile.ZipFile(f, "r") as zipfp:
606 zinfo = zipfp.getinfo('strfile')
615 with zipfile.ZipFile(TESTFN2, "w") as zipfp:
617 zipfp.writestr(fpath, fdata)
618 self.assertTrue(zipfp.fp is not None, 'zipfp is not open')
619 self.assertTrue(zipfp.fp is None, 'zipfp is not closed')
621 with zipfile.ZipFile(TESTFN2, "r") as zipfp:
622 self.assertTrue(zipfp.fp is not None, 'zipfp is not open')
623 self.assertTrue(zipfp.fp is None, 'zipfp is not closed')
628 with zipfile.ZipFile(TESTFN2, "w") as zipfp:
630 zipfp.writestr(fpath, fdata)
636 self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')
641 with zipfile.ZipFile(TESTFN2, "w") as zipfp:
642 self.assertRaises(ValueError, zipfp.write, TESTFN)
668 with zipfile.ZipFile(f, "w", compression) as zipfp:
670 zipfp.write, TESTFN, "another.name")
673 with zipfile.ZipFile(f, "w", compression) as zipfp:
675 zipfp.writestr, "another.name", self.data)
684 with zipfile.ZipFile(f, "w", compression, allowZip64=True) as zipfp:
685 zipfp.write(TESTFN, "another.name")
686 zipfp.write(TESTFN, TESTFN)
687 zipfp.writestr("strfile", self.data)
690 with zipfile.ZipFile(f, "r", compression) as zipfp:
691 self.assertEqual(zipfp.read(TESTFN), self.data)
692 self.assertEqual(zipfp.read("another.name"), self.data)
693 self.assertEqual(zipfp.read("strfile"), self.data)
700 zipfp.printdir()
719 names = zipfp.namelist()
726 infos = zipfp.infolist()
737 info = zipfp.getinfo(nm)
742 zipfp.testzip()
755 allowZip64=True) as zipfp:
756 zipfp.write(TESTFN, "/absolute")
758 with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:
759 self.assertEqual(zipfp.namelist(), ["absolute"])
836 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
841 zipfp.writepy(fn)
844 self.assertNotIn(bn, zipfp.namelist())
845 self.assertTrue(bn + 'o' in zipfp.namelist() or
846 bn + 'c' in zipfp.namelist())
848 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
853 zipfp.writepy(fn, "testpackage")
856 self.assertNotIn(bn, zipfp.namelist())
857 self.assertTrue(bn + 'o' in zipfp.namelist() or
858 bn + 'c' in zipfp.namelist())
865 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
866 zipfp.writepy(packagedir)
870 names = zipfp.namelist()
888 zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
889 zipfp.writepy(TESTFN2)
891 names = zipfp.namelist()
900 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
903 self.assertRaises(RuntimeError, zipfp.writepy, TESTFN)
1372 with zipfile.ZipFile(f, "w", compression) as zipfp:
1373 zipfp.write(TESTFN, "another.name")
1374 zipfp.write(TESTFN, TESTFN)
1380 with zipfile.ZipFile(f, "r", compression) as zipfp:
1381 testdata = zipfp.read(TESTFN)
1384 self.assertEqual(zipfp.read("another.name"), self.data)
1399 with zipfile.ZipFile(f, "r", compression) as zipfp:
1401 with zipfp.open(TESTFN) as zipopen1:
1409 with zipfp.open("another.name") as zipopen2:
1437 with zipfile.ZipFile(f, "r", compression) as zipfp:
1439 with zipfp.open(TESTFN) as zipopen1:
1469 with zipfile.ZipFile(f, "w", zipfile.ZIP_DEFLATED) as zipfp:
1470 zipfp.writestr('ones', self.data1)
1471 zipfp.writestr('twos', self.data2)
1652 with zipfile.ZipFile(f, "w", compression) as zipfp:
1654 zipfp.write(fn, fn)
1660 with zipfile.ZipFile(f, "r") as zipfp:
1662 with zipfp.open(fn, "rU") as fp:
1670 zipfp = zipfile.ZipFile(f, "r")
1672 with zipfp.open(fn, "rU") as zipopen:
1687 zipfp.close()
1693 with zipfile.ZipFile(f, "r") as zipfp:
1695 with zipfp.open(fn, "rU") as zipopen:
1704 with zipfile.ZipFile(f, "r") as zipfp:
1706 with zipfp.open(fn, "rU") as fp:
1715 with zipfile.ZipFile(f, "r") as zipfp:
1717 with zipfp.open(fn, "rU") as fid: