from tempfile import TemporaryFile
from random import randint, random
+import test.test_support as support
from test.test_support import TESTFN, run_unittest
TESTFN2 = TESTFN + "2"
self.assertEqual(zf.read(filename), content)
zf.close()
- os.unlink(TESTFN)
-
def testCloseErroneousFile(self):
# This test checks that the ZipFile constructor closes the file object
# it opens if there's an error in the file. If it doesn't, the traceback
try:
zf = zipfile.ZipFile(TESTFN)
except zipfile.BadZipfile:
- os.unlink(TESTFN)
+ pass
def testIsZipErroneousFile(self):
# This test checks that the is_zipfile function correctly identifies
fp.write("this is not a legal zip file\n")
fp.close()
chk = zipfile.is_zipfile(TESTFN)
- os.unlink(TESTFN)
self.assert_(chk is False)
def testIsZipValidFile(self):
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
zipf.close()
chk = zipfile.is_zipfile(TESTFN)
- os.unlink(TESTFN)
self.assert_(chk is True)
def testNonExistentFileRaisesIOError(self):
# version of .testzip would swallow this exception (and any other)
# and report that the first file in the archive was corrupt.
self.assertRaises(RuntimeError, zipf.testzip)
+
+ def tearDown(self):
+ support.unlink(TESTFN)
+ support.unlink(TESTFN2)
class DecryptionTests(unittest.TestCase):
# This test checks that ZIP decryption works. Since the library does not
fp = open(TESTFN, "wb")
fp.write(self.data)
fp.close()
+
+ def tearDown(self):
+ support.unlink(TESTFN)
+ support.unlink(TESTFN2)
def makeTestArchive(self, f, compression):
# Create the ZIP archive
def tearDown(self):
for sep, fn in self.arcfiles.items():
os.remove(fn)
+ support.unlink(TESTFN)
+ support.unlink(TESTFN2)
def test_main():
PyZipFileTests, DecryptionTests, TestsWithMultipleOpens,
UniversalNewlineTests, TestsWithRandomBinaryFiles)
- #run_unittest(TestZip64InSmallFiles)
-
if __name__ == "__main__":
test_main()