~pythonregexp2.7/python/issue2636-01+09-02

« back to all changes in this revision

Viewing changes to Lib/test/test_zipfile64.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:16:16 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922001616-p1wdip9lfp0zl5cu
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# The test_support.requires call is the only reason for keeping this separate
3
3
# from test_zipfile
4
4
from test import test_support
 
5
 
5
6
# XXX(nnorwitz): disable this test by looking for extra largfile resource
6
7
# which doesn't exist.  This test takes over 30 minutes to run in general
7
8
# and requires more disk space than most of the buildbots.
93
94
            if os.path.exists(fname):
94
95
                os.remove(fname)
95
96
 
 
97
 
 
98
class OtherTests(unittest.TestCase):
 
99
    def testMoreThan64kFiles(self):
 
100
        # This test checks that more than 64k files can be added to an archive,
 
101
        # and that the resulting archive can be read properly by ZipFile
 
102
        zipf = zipfile.ZipFile(TESTFN, mode="w")
 
103
        zipf.debug = 100
 
104
        numfiles = (1 << 16) * 3/2
 
105
        for i in xrange(numfiles):
 
106
            zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57))
 
107
        self.assertEqual(len(zipf.namelist()), numfiles)
 
108
        zipf.close()
 
109
 
 
110
        zipf2 = zipfile.ZipFile(TESTFN, mode="r")
 
111
        self.assertEqual(len(zipf2.namelist()), numfiles)
 
112
        for i in xrange(numfiles):
 
113
            self.assertEqual(zipf2.read("foo%08d" % i), "%d" % (i**3 % 57))
 
114
        zipf.close()
 
115
 
 
116
    def tearDown(self):
 
117
        test_support.unlink(TESTFN)
 
118
        test_support.unlink(TESTFN2)
 
119
 
96
120
def test_main():
97
 
    run_unittest(TestsWithSourceFile)
 
121
    run_unittest(TestsWithSourceFile, OtherTests)
98
122
 
99
123
if __name__ == "__main__":
100
124
    test_main()