diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2009-09-12 14:43:43 +0000 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2009-09-12 14:43:43 +0000 |
commit | 1036a7f7e180ac3fd98e43832a04e38b4c7c9e83 (patch) | |
tree | eab29c294a6bbc075d44281c91d7ae433f3c96d0 /Lib/test | |
parent | 21121e64b4245e51b85b9d2bc9b29acb86ae79eb (diff) | |
download | cpython-git-1036a7f7e180ac3fd98e43832a04e38b4c7c9e83.tar.gz |
#6026 - fix tests that failed without zlib
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_gzip.py | 3 | ||||
-rw-r--r-- | Lib/test/test_zipfile.py | 3 | ||||
-rw-r--r-- | Lib/test/test_zipimport.py | 13 |
3 files changed, 14 insertions, 5 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 8ae31b29de..13b0e57c12 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -5,9 +5,8 @@ import unittest from test import test_support import os -import gzip import struct - +gzip = test_support.import_module('gzip') data1 = """ int length=DEFAULTALLOC, err = Z_OK; PyObject *RetVal; diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 652274f8fe..3f86b32adb 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -311,6 +311,7 @@ class TestsWithSourceFile(unittest.TestCase): self.assertEqual(zipfp.read(TESTFN), file(TESTFN).read()) zipfp.close() + @skipUnless(zlib, "requires zlib") def test_per_file_compression(self): # Check that files within a Zip archive can have different compression options zipfp = zipfile.ZipFile(TESTFN2, "w") @@ -882,6 +883,7 @@ class DecryptionTests(unittest.TestCase): self.zip2.setpassword("perl") self.assertRaises(RuntimeError, self.zip2.read, "zero") + @skipUnless(zlib, "requires zlib") def test_good_password(self): self.zip.setpassword("python") self.assertEquals(self.zip.read("test.txt"), self.plain) @@ -982,6 +984,7 @@ class TestsWithRandomBinaryFiles(unittest.TestCase): self.zip_random_open_test(f, zipfile.ZIP_STORED) +@skipUnless(zlib, "requires zlib") class TestsWithMultipleOpens(unittest.TestCase): def setUp(self): # Create the ZIP archive diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 30722309ae..f15958ce91 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -6,11 +6,17 @@ import struct import time import unittest -import zlib # implied prerequisite -from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED from test import test_support from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co +# some tests can be ran even without zlib +try: + import zlib +except ImportError: + zlib = None + +from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED + import zipimport import linecache import doctest @@ -53,6 +59,7 @@ TESTPACK = "ziptestpackage" TESTPACK2 = "ziptestpackage2" TEMP_ZIP = os.path.abspath("junk95142" + os.extsep + "zip") + class UncompressedZipImportTestCase(ImportHooksBaseTestCase): compression = ZIP_STORED @@ -357,7 +364,6 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): def testDoctestSuite(self): self.runDoctest(self.doDoctestSuite) - def doTraceback(self, module): try: module.do_raise() @@ -381,6 +387,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): self.doTest(None, files, TESTMOD, call=self.doTraceback) +@unittest.skipUnless(zlib, "requires zlib") class CompressedZipImportTestCase(UncompressedZipImportTestCase): compression = ZIP_DEFLATED |