summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2009-09-12 18:41:20 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2009-09-12 18:41:20 (GMT)
commit78ea2023d8aaac460ef921c45a20053159dec613 (patch)
treee60fbfd5532a3e8a5430b68f76de05e0724188a5
parent049d2aa952ae8deb8932a2b84aa1d503b83ad6a5 (diff)
downloadcpython-78ea2023d8aaac460ef921c45a20053159dec613.zip
cpython-78ea2023d8aaac460ef921c45a20053159dec613.tar.gz
cpython-78ea2023d8aaac460ef921c45a20053159dec613.tar.bz2
Merged revisions 74754 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74754 | ezio.melotti | 2009-09-12 17:43:43 +0300 (Sat, 12 Sep 2009) | 1 line #6026 - fix tests that failed without zlib ........
-rw-r--r--Lib/distutils/tests/test_archive_util.py10
-rw-r--r--Lib/distutils/tests/test_bdist_dumb.py8
-rw-r--r--Lib/distutils/tests/test_sdist.py12
-rw-r--r--Lib/sqlite3/test/types.py8
-rw-r--r--Lib/test/test_gzip.py3
-rw-r--r--Lib/test/test_zipfile.py3
-rw-r--r--Lib/test/test_zipimport.py13
7 files changed, 51 insertions, 6 deletions
diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
index d88e0b3..d33b7e1 100644
--- a/Lib/distutils/tests/test_archive_util.py
+++ b/Lib/distutils/tests/test_archive_util.py
@@ -19,10 +19,18 @@ try:
except ImportError:
ZIP_SUPPORT = find_executable('zip')
+# some tests will fail if zlib is not available
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
+
class ArchiveUtilTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
+ @unittest.skipUnless(zlib, "Requires zlib")
def test_make_tarball(self):
# creating something to tar
tmpdir = self.mkdtemp()
@@ -83,6 +91,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
base_name = os.path.join(tmpdir2, 'archive')
return tmpdir, tmpdir2, base_name
+ @unittest.skipUnless(zlib, "Requires zlib")
@unittest.skipUnless(find_executable('tar') and find_executable('gzip'),
'Need the tar command to run')
def test_tarfile_vs_tar(self):
@@ -168,6 +177,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
self.assertTrue(not os.path.exists(tarball))
self.assertEquals(len(w.warnings), 1)
+ @unittest.skipUnless(zlib, "Requires zlib")
@unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
def test_make_zipfile(self):
# creating something to tar
diff --git a/Lib/distutils/tests/test_bdist_dumb.py b/Lib/distutils/tests/test_bdist_dumb.py
index b28f89f..a838f73 100644
--- a/Lib/distutils/tests/test_bdist_dumb.py
+++ b/Lib/distutils/tests/test_bdist_dumb.py
@@ -4,6 +4,13 @@ import unittest
import sys
import os
+# zlib is not used here, but if it's not available
+# test_simple_built will fail
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
from distutils.core import Distribution
from distutils.command.bdist_dumb import bdist_dumb
from distutils.tests import support
@@ -31,6 +38,7 @@ class BuildDumbTestCase(support.TempdirManager,
sys.argv = self.old_sys_argv[:]
super(BuildDumbTestCase, self).tearDown()
+ @unittest.skipUnless(zlib, "requires zlib")
def test_simple_built(self):
# let's create a simple package
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index b7e5859..986288e 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -3,6 +3,14 @@ import os
import unittest
import shutil
import zipfile
+
+# zlib is not used here, but if it's not available
+# the tests that use zipfile may fail
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
from os.path import join
import sys
import tempfile
@@ -79,6 +87,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd.warn = _warn
return dist, cmd
+ @unittest.skipUnless(zlib, "requires zlib")
def test_prune_file_list(self):
# this test creates a package with some vcs dirs in it
# and launch sdist to make sure they get pruned
@@ -120,6 +129,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# making sure everything has been pruned correctly
self.assertEquals(len(content), 4)
+ @unittest.skipUnless(zlib, "requires zlib")
def test_make_distribution(self):
# check if tar and gzip are installed
@@ -156,6 +166,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
self.assertEquals(result,
['fake-1.0.tar', 'fake-1.0.tar.gz'])
+ @unittest.skipUnless(zlib, "requires zlib")
def test_add_defaults(self):
# http://bugs.python.org/issue2279
@@ -217,6 +228,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
manifest = open(join(self.tmp_dir, 'MANIFEST')).read()
self.assertEquals(manifest, MANIFEST % {'sep': os.sep})
+ @unittest.skipUnless(zlib, "requires zlib")
def test_metadata_check_option(self):
# testing the `medata-check` option
dist, cmd = self.get_cmd(metadata={})
diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py
index 8b1d780..26494e1 100644
--- a/Lib/sqlite3/test/types.py
+++ b/Lib/sqlite3/test/types.py
@@ -21,9 +21,14 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
-import zlib, datetime
+import datetime
import unittest
import sqlite3 as sqlite
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
class SqliteTypeTests(unittest.TestCase):
def setUp(self):
@@ -312,6 +317,7 @@ class ObjectAdaptationTests(unittest.TestCase):
val = self.cur.fetchone()[0]
self.assertEqual(type(val), float)
+@unittest.skipUnless(zlib, "requires zlib")
class BinaryConverterTests(unittest.TestCase):
def convert(s):
return zlib.decompress(s)
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index d928635..fa91dc0 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -5,9 +5,8 @@
import unittest
from test import support
import os
-import gzip
import struct
-
+gzip = support.import_module('gzip')
data1 = b""" int length=DEFAULTALLOC, err = Z_OK;
PyObject *RetVal;
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index b17f857..76be41c 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -307,6 +307,7 @@ class TestsWithSourceFile(unittest.TestCase):
self.assertEqual(zipfp.read(TESTFN), open(TESTFN, "rb").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")
@@ -881,6 +882,7 @@ class DecryptionTests(unittest.TestCase):
self.zip2.setpassword(b"perl")
self.assertRaises(RuntimeError, self.zip2.read, "zero")
+ @skipUnless(zlib, "requires zlib")
def test_good_password(self):
self.zip.setpassword(b"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 5d163c7..62440e1 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 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.zip")
+
class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
compression = ZIP_STORED
@@ -354,7 +361,6 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
def testDoctestSuite(self):
self.runDoctest(self.doDoctestSuite)
-
def doTraceback(self, module):
try:
module.do_raise()
@@ -378,6 +384,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
self.doTest(None, files, TESTMOD, call=self.doTraceback)
+@unittest.skipUnless(zlib, "requires zlib")
class CompressedZipImportTestCase(UncompressedZipImportTestCase):
compression = ZIP_DEFLATED