Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3be2f04

Browse files
committed
#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.
1 parent e255764 commit 3be2f04

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Lib/test/test_zipfile64.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TestsWithSourceFile(unittest.TestCase):
3535
def setUp(self):
3636
# Create test data.
3737
line_gen = ("Test of zipfile line %d." % i for i in range(1000000))
38-
self.data = '\n'.join(line_gen)
38+
self.data = '\n'.join(line_gen).encode('ascii')
3939

4040
# And write it to a file.
4141
fp = open(TESTFN, "wb")
@@ -100,21 +100,22 @@ def testMoreThan64kFiles(self):
100100
# and that the resulting archive can be read properly by ZipFile
101101
zipf = zipfile.ZipFile(TESTFN, mode="w")
102102
zipf.debug = 100
103-
numfiles = (1 << 16) * 3/2
104-
for i in xrange(numfiles):
103+
numfiles = (1 << 16) * 3//2
104+
for i in range(numfiles):
105105
zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57))
106106
self.assertEqual(len(zipf.namelist()), numfiles)
107107
zipf.close()
108108

109109
zipf2 = zipfile.ZipFile(TESTFN, mode="r")
110110
self.assertEqual(len(zipf2.namelist()), numfiles)
111-
for i in xrange(numfiles):
112-
self.assertEqual(zipf2.read("foo%08d" % i), "%d" % (i**3 % 57))
111+
for i in range(numfiles):
112+
content = zipf2.read("foo%08d" % i).decode('ascii')
113+
self.assertEqual(content, "%d" % (i**3 % 57))
113114
zipf.close()
114115

115116
def tearDown(self):
116-
test_support.unlink(TESTFN)
117-
test_support.unlink(TESTFN2)
117+
support.unlink(TESTFN)
118+
support.unlink(TESTFN2)
118119

119120
def test_main():
120121
run_unittest(TestsWithSourceFile, OtherTests)

0 commit comments

Comments
 (0)