Commit a706937e authored by Ezio Melotti's avatar Ezio Melotti

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
........
parent 031ebb0f
...@@ -19,10 +19,18 @@ try: ...@@ -19,10 +19,18 @@ try:
except ImportError: except ImportError:
ZIP_SUPPORT = find_executable('zip') 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, class ArchiveUtilTestCase(support.TempdirManager,
support.LoggingSilencer, support.LoggingSilencer,
unittest.TestCase): unittest.TestCase):
@unittest.skipUnless(zlib, "Requires zlib")
def test_make_tarball(self): def test_make_tarball(self):
# creating something to tar # creating something to tar
tmpdir = self.mkdtemp() tmpdir = self.mkdtemp()
...@@ -83,6 +91,7 @@ class ArchiveUtilTestCase(support.TempdirManager, ...@@ -83,6 +91,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
base_name = os.path.join(tmpdir2, 'archive') base_name = os.path.join(tmpdir2, 'archive')
return tmpdir, tmpdir2, base_name return tmpdir, tmpdir2, base_name
@unittest.skipUnless(zlib, "Requires zlib")
@unittest.skipUnless(find_executable('tar') and find_executable('gzip'), @unittest.skipUnless(find_executable('tar') and find_executable('gzip'),
'Need the tar command to run') 'Need the tar command to run')
def test_tarfile_vs_tar(self): def test_tarfile_vs_tar(self):
...@@ -168,6 +177,7 @@ class ArchiveUtilTestCase(support.TempdirManager, ...@@ -168,6 +177,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
self.assertTrue(not os.path.exists(tarball)) self.assertTrue(not os.path.exists(tarball))
self.assertEquals(len(w.warnings), 1) self.assertEquals(len(w.warnings), 1)
@unittest.skipUnless(zlib, "Requires zlib")
@unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run') @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
def test_make_zipfile(self): def test_make_zipfile(self):
# creating something to tar # creating something to tar
......
...@@ -4,6 +4,13 @@ import unittest ...@@ -4,6 +4,13 @@ import unittest
import sys import sys
import os 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.core import Distribution
from distutils.command.bdist_dumb import bdist_dumb from distutils.command.bdist_dumb import bdist_dumb
from distutils.tests import support from distutils.tests import support
...@@ -31,6 +38,7 @@ class BuildDumbTestCase(support.TempdirManager, ...@@ -31,6 +38,7 @@ class BuildDumbTestCase(support.TempdirManager,
sys.argv = self.old_sys_argv[:] sys.argv = self.old_sys_argv[:]
super(BuildDumbTestCase, self).tearDown() super(BuildDumbTestCase, self).tearDown()
@unittest.skipUnless(zlib, "requires zlib")
def test_simple_built(self): def test_simple_built(self):
# let's create a simple package # let's create a simple package
......
...@@ -3,6 +3,14 @@ import os ...@@ -3,6 +3,14 @@ import os
import unittest import unittest
import shutil import shutil
import zipfile 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 from os.path import join
import sys import sys
import tempfile import tempfile
...@@ -79,6 +87,7 @@ class SDistTestCase(PyPIRCCommandTestCase): ...@@ -79,6 +87,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd.warn = _warn cmd.warn = _warn
return dist, cmd return dist, cmd
@unittest.skipUnless(zlib, "requires zlib")
def test_prune_file_list(self): def test_prune_file_list(self):
# this test creates a package with some vcs dirs in it # this test creates a package with some vcs dirs in it
# and launch sdist to make sure they get pruned # and launch sdist to make sure they get pruned
...@@ -120,6 +129,7 @@ class SDistTestCase(PyPIRCCommandTestCase): ...@@ -120,6 +129,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# making sure everything has been pruned correctly # making sure everything has been pruned correctly
self.assertEquals(len(content), 4) self.assertEquals(len(content), 4)
@unittest.skipUnless(zlib, "requires zlib")
def test_make_distribution(self): def test_make_distribution(self):
# check if tar and gzip are installed # check if tar and gzip are installed
...@@ -156,6 +166,7 @@ class SDistTestCase(PyPIRCCommandTestCase): ...@@ -156,6 +166,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
self.assertEquals(result, self.assertEquals(result,
['fake-1.0.tar', 'fake-1.0.tar.gz']) ['fake-1.0.tar', 'fake-1.0.tar.gz'])
@unittest.skipUnless(zlib, "requires zlib")
def test_add_defaults(self): def test_add_defaults(self):
# http://bugs.python.org/issue2279 # http://bugs.python.org/issue2279
...@@ -217,6 +228,7 @@ class SDistTestCase(PyPIRCCommandTestCase): ...@@ -217,6 +228,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
manifest = open(join(self.tmp_dir, 'MANIFEST')).read() manifest = open(join(self.tmp_dir, 'MANIFEST')).read()
self.assertEquals(manifest, MANIFEST % {'sep': os.sep}) self.assertEquals(manifest, MANIFEST % {'sep': os.sep})
@unittest.skipUnless(zlib, "requires zlib")
def test_metadata_check_option(self): def test_metadata_check_option(self):
# testing the `medata-check` option # testing the `medata-check` option
dist, cmd = self.get_cmd(metadata={}) dist, cmd = self.get_cmd(metadata={})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment