diff options
Diffstat (limited to 'Lib/test/test_zipfile64.py')
-rw-r--r-- | Lib/test/test_zipfile64.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py index a6f3dca4b9c..0e7d73f1fff 100644 --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -1,12 +1,12 @@ # Tests of the full ZIP64 functionality of zipfile -# The test_support.requires call is the only reason for keeping this separate +# The support.requires call is the only reason for keeping this separate # from test_zipfile -from test import test_support +from test import support # XXX(nnorwitz): disable this test by looking for extra largfile resource # which doesn't exist. This test takes over 30 minutes to run in general # and requires more disk space than most of the buildbots. -test_support.requires( +support.requires( 'extralargefile', 'test requires loads of disk-space bytes and a long time to run' ) @@ -21,9 +21,10 @@ import zipfile, os, unittest import time import sys +from io import StringIO from tempfile import TemporaryFile -from test.test_support import TESTFN, run_unittest +from test.support import TESTFN, run_unittest TESTFN2 = TESTFN + "2" @@ -33,10 +34,8 @@ _PRINT_WORKING_MSG_INTERVAL = 5 * 60 class TestsWithSourceFile(unittest.TestCase): def setUp(self): # Create test data. - # xrange() is important here -- don't want to create immortal space - # for a million ints. - line_gen = ("Test of zipfile line %d." % i for i in xrange(1000000)) - self.data = '\n'.join(line_gen) + line_gen = ("Test of zipfile line %d." % i for i in range(1000000)) + self.data = '\n'.join(line_gen).encode('ascii') # And write it to a file. fp = open(TESTFN, "wb") @@ -57,9 +56,9 @@ class TestsWithSourceFile(unittest.TestCase): # Print still working message since this test can be really slow if next_time <= time.time(): next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL - print >>sys.__stdout__, ( + print(( ' zipTest still writing %d of %d, be patient...' % - (num, filecount)) + (num, filecount)), file=sys.__stdout__) sys.__stdout__.flush() zipfp.close() @@ -70,9 +69,9 @@ class TestsWithSourceFile(unittest.TestCase): # Print still working message since this test can be really slow if next_time <= time.time(): next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL - print >>sys.__stdout__, ( + print(( ' zipTest still reading %d of %d, be patient...' % - (num, filecount)) + (num, filecount)), file=sys.__stdout__) sys.__stdout__.flush() zipfp.close() @@ -101,21 +100,22 @@ class OtherTests(unittest.TestCase): # and that the resulting archive can be read properly by ZipFile zipf = zipfile.ZipFile(TESTFN, mode="w") zipf.debug = 100 - numfiles = (1 << 16) * 3/2 - for i in xrange(numfiles): + numfiles = (1 << 16) * 3//2 + for i in range(numfiles): zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57)) self.assertEqual(len(zipf.namelist()), numfiles) zipf.close() zipf2 = zipfile.ZipFile(TESTFN, mode="r") self.assertEqual(len(zipf2.namelist()), numfiles) - for i in xrange(numfiles): - self.assertEqual(zipf2.read("foo%08d" % i), "%d" % (i**3 % 57)) + for i in range(numfiles): + content = zipf2.read("foo%08d" % i).decode('ascii') + self.assertEqual(content, "%d" % (i**3 % 57)) zipf.close() def tearDown(self): - test_support.unlink(TESTFN) - test_support.unlink(TESTFN2) + support.unlink(TESTFN) + support.unlink(TESTFN2) def test_main(): run_unittest(TestsWithSourceFile, OtherTests) |