1111 'test requires loads of disk-space bytes and a long time to run'
1212 )
1313
14- import zipfile , os , unittest
14+ import zipfile , unittest
1515import time
1616import sys
1717
@@ -32,10 +32,6 @@ def setUp(self):
3232 line_gen = ("Test of zipfile line %d." % i for i in range (1000000 ))
3333 self .data = '\n ' .join (line_gen ).encode ('ascii' )
3434
35- # And write it to a file.
36- with open (TESTFN , "wb" ) as fp :
37- fp .write (self .data )
38-
3935 def zipTest (self , f , compression ):
4036 # Create the ZIP archive.
4137 with zipfile .ZipFile (f , "w" , compression ) as zipfp :
@@ -67,6 +63,9 @@ def zipTest(self, f, compression):
6763 (num , filecount )), file = sys .__stdout__ )
6864 sys .__stdout__ .flush ()
6965
66+ # Check that testzip thinks the archive is valid
67+ self .assertIsNone (zipfp .testzip ())
68+
7069 def testStored (self ):
7170 # Try the temp file first. If we do TESTFN2 first, then it hogs
7271 # gigabytes of disk space for the duration of the test.
@@ -85,9 +84,7 @@ def testDeflated(self):
8584 self .zipTest (TESTFN2 , zipfile .ZIP_DEFLATED )
8685
8786 def tearDown (self ):
88- for fname in TESTFN , TESTFN2 :
89- if os .path .exists (fname ):
90- os .remove (fname )
87+ os_helper .unlink (TESTFN2 )
9188
9289
9390class OtherTests (unittest .TestCase ):
0 commit comments