(self)
| 89 | |
| 90 | class OtherTests(unittest.TestCase): |
| 91 | def testMoreThan64kFiles(self): |
| 92 | # This test checks that more than 64k files can be added to an archive, |
| 93 | # and that the resulting archive can be read properly by ZipFile |
| 94 | with zipfile.ZipFile(TESTFN, mode="w", allowZip64=True) as zipf: |
| 95 | zipf.debug = 100 |
| 96 | numfiles = (1 << 16) * 3//2 |
| 97 | for i in range(numfiles): |
| 98 | zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57)) |
| 99 | self.assertEqual(len(zipf.namelist()), numfiles) |
| 100 | |
| 101 | with zipfile.ZipFile(TESTFN, mode="r") as zipf2: |
| 102 | self.assertEqual(len(zipf2.namelist()), numfiles) |
| 103 | for i in range(numfiles): |
| 104 | content = zipf2.read("foo%08d" % i).decode('ascii') |
| 105 | self.assertEqual(content, "%d" % (i**3 % 57)) |
| 106 | |
| 107 | def testMoreThan64kFilesAppend(self): |
| 108 | with zipfile.ZipFile(TESTFN, mode="w", allowZip64=False) as zipf: |
nothing calls this directly
no test coverage detected