Commit 3be2f045 authored by Amaury Forgeot d'Arc's avatar Amaury Forgeot d'Arc

#2971: test_zipfile64 fails.

This test is always skipped, but it is not a reason not to adapt it to py3k.

I had to reduce most of the big figures to actually run the test.
parent e2557646
...@@ -35,7 +35,7 @@ class TestsWithSourceFile(unittest.TestCase): ...@@ -35,7 +35,7 @@ class TestsWithSourceFile(unittest.TestCase):
def setUp(self): def setUp(self):
# Create test data. # Create test data.
line_gen = ("Test of zipfile line %d." % i for i in range(1000000)) line_gen = ("Test of zipfile line %d." % i for i in range(1000000))
self.data = '\n'.join(line_gen) self.data = '\n'.join(line_gen).encode('ascii')
# And write it to a file. # And write it to a file.
fp = open(TESTFN, "wb") fp = open(TESTFN, "wb")
...@@ -100,21 +100,22 @@ class OtherTests(unittest.TestCase): ...@@ -100,21 +100,22 @@ class OtherTests(unittest.TestCase):
# and that the resulting archive can be read properly by ZipFile # and that the resulting archive can be read properly by ZipFile
zipf = zipfile.ZipFile(TESTFN, mode="w") zipf = zipfile.ZipFile(TESTFN, mode="w")
zipf.debug = 100 zipf.debug = 100
numfiles = (1 << 16) * 3/2 numfiles = (1 << 16) * 3//2
for i in xrange(numfiles): for i in range(numfiles):
zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57)) zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57))
self.assertEqual(len(zipf.namelist()), numfiles) self.assertEqual(len(zipf.namelist()), numfiles)
zipf.close() zipf.close()
zipf2 = zipfile.ZipFile(TESTFN, mode="r") zipf2 = zipfile.ZipFile(TESTFN, mode="r")
self.assertEqual(len(zipf2.namelist()), numfiles) self.assertEqual(len(zipf2.namelist()), numfiles)
for i in xrange(numfiles): for i in range(numfiles):
self.assertEqual(zipf2.read("foo%08d" % i), "%d" % (i**3 % 57)) content = zipf2.read("foo%08d" % i).decode('ascii')
self.assertEqual(content, "%d" % (i**3 % 57))
zipf.close() zipf.close()
def tearDown(self): def tearDown(self):
test_support.unlink(TESTFN) support.unlink(TESTFN)
test_support.unlink(TESTFN2) support.unlink(TESTFN2)
def test_main(): def test_main():
run_unittest(TestsWithSourceFile, OtherTests) run_unittest(TestsWithSourceFile, OtherTests)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment