[Python-checkins] cpython: Skip tests that require zlib in the packaging tests. Also add a requires_zlib
ezio.melotti
python-checkins at python.org
Thu May 19 20:25:23 CEST 2011
http://hg.python.org/cpython/rev/cfa2feb39c1f
changeset: 70208:cfa2feb39c1f
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Thu May 19 21:25:10 2011 +0300
summary:
Skip tests that require zlib in the packaging tests. Also add a requires_zlib decorator to test.support.
files:
Lib/packaging/tests/support.py | 3 +-
Lib/packaging/tests/test_command_sdist.py | 22 +++++-----
Lib/packaging/tests/test_config.py | 2 +
Lib/packaging/tests/test_database.py | 8 ++++
Lib/packaging/tests/test_depgraph.py | 8 ++++
Lib/packaging/tests/test_pypi_dist.py | 3 +-
Lib/test/support.py | 9 ++++-
7 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py
--- a/Lib/packaging/tests/support.py
+++ b/Lib/packaging/tests/support.py
@@ -37,10 +37,11 @@
from packaging import logger
from packaging.dist import Distribution
from packaging.tests import unittest
+from test.support import requires_zlib
__all__ = ['LoggingCatcher', 'TempdirManager', 'EnvironRestorer',
'DummyCommand', 'unittest', 'create_distribution',
- 'skip_unless_symlink']
+ 'skip_unless_symlink', 'requires_zlib']
class _TestHandler(logging.handlers.BufferingHandler):
diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py
--- a/Lib/packaging/tests/test_command_sdist.py
+++ b/Lib/packaging/tests/test_command_sdist.py
@@ -4,12 +4,7 @@
import tarfile
import logging
-# 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 packaging.tests.support import requires_zlib
try:
import grp
@@ -96,7 +91,7 @@
cmd.dist_dir = 'dist'
return dist, cmd
- @unittest.skipUnless(zlib, "requires 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
@@ -136,7 +131,7 @@
# making sure everything has been pruned correctly
self.assertEqual(len(content), 3)
- @unittest.skipUnless(zlib, "requires zlib")
+ @requires_zlib
@unittest.skipIf(find_executable('tar') is None or
find_executable('gzip') is None,
'requires tar and gzip programs')
@@ -166,7 +161,7 @@
result = sorted(os.listdir(dist_folder))
self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
- @unittest.skipUnless(zlib, "requires zlib")
+ @requires_zlib
def test_add_defaults(self):
# http://bugs.python.org/issue2279
@@ -226,7 +221,7 @@
manifest = fp.read()
self.assertEqual(manifest, MANIFEST % {'sep': os.sep})
- @unittest.skipUnless(zlib, "requires zlib")
+ @requires_zlib
def test_metadata_check_option(self):
# testing the `check-metadata` option
dist, cmd = self.get_cmd(metadata={'name': 'xxx', 'version': 'xxx'})
@@ -280,7 +275,7 @@
cmd.formats = 'supazipa'
self.assertRaises(PackagingOptionError, cmd.finalize_options)
- @unittest.skipUnless(zlib, "requires zlib")
+ @requires_zlib
@unittest.skipUnless(UID_GID_SUPPORT, "requires grp and pwd support")
@unittest.skipIf(find_executable('tar') is None or
find_executable('gzip') is None,
@@ -321,6 +316,7 @@
for member in archive.getmembers():
self.assertEqual(member.uid, os.getuid())
+ @requires_zlib
def test_get_file_list(self):
# make sure MANIFEST is recalculated
dist, cmd = self.get_cmd()
@@ -355,6 +351,7 @@
self.assertEqual(len(manifest2), 5)
self.assertIn('doc2.txt', manifest2[-1])
+ @requires_zlib
def test_manifest_marker(self):
# check that autogenerated MANIFESTs have a marker
dist, cmd = self.get_cmd()
@@ -368,6 +365,7 @@
self.assertEqual(manifest[0],
'# file GENERATED by packaging, do NOT edit')
+ @requires_zlib
def test_manual_manifest(self):
# check that a MANIFEST without a marker is left alone
dist, cmd = self.get_cmd()
@@ -381,6 +379,7 @@
self.assertEqual(manifest, ['README.manual'])
+ @requires_zlib
def test_template(self):
dist, cmd = self.get_cmd()
dist.extra_files = ['include yeah']
@@ -392,6 +391,7 @@
self.assertIn('yeah', content)
+ @requires_zlib
def test_manifest_builder(self):
dist, cmd = self.get_cmd()
cmd.manifest_builders = 'packaging.tests.test_command_sdist.builder'
diff --git a/Lib/packaging/tests/test_config.py b/Lib/packaging/tests/test_config.py
--- a/Lib/packaging/tests/test_config.py
+++ b/Lib/packaging/tests/test_config.py
@@ -11,6 +11,7 @@
from packaging.command.sdist import sdist
from packaging.tests import unittest, support
+from packaging.tests.support import requires_zlib
SETUP_CFG = """
@@ -343,6 +344,7 @@
cmd.get_file_list()
self.assertRaises(PackagingFileError, cmd.make_distribution)
+ @requires_zlib
def test_metadata_requires_description_files(self):
# Create the following file structure:
# README
diff --git a/Lib/packaging/tests/test_database.py b/Lib/packaging/tests/test_database.py
--- a/Lib/packaging/tests/test_database.py
+++ b/Lib/packaging/tests/test_database.py
@@ -12,6 +12,7 @@
from packaging.errors import PackagingError
from packaging.metadata import Metadata
from packaging.tests import unittest, run_unittest, support, TESTFN
+from packaging.tests.support import requires_zlib
from packaging.database import (
Distribution, EggInfoDistribution, get_distribution, get_distributions,
@@ -64,11 +65,13 @@
self.assertEqual(dist.version, version)
self.assertEqual(dist.metadata['Version'], version)
+ @requires_zlib
def test_repr(self):
dist = self.cls(self.dirs[0])
# just check that the class name is in the repr
self.assertIn(self.cls.__name__, repr(dist))
+ @requires_zlib
def test_comparison(self):
# tests for __eq__ and __hash__
dist = self.cls(self.dirs[0])
@@ -281,6 +284,7 @@
dirname = distinfo_dirname(name, version)
self.assertEqual(dirname, standard_dirname)
+ @requires_zlib
def test_get_distributions(self):
# Lookup all distributions found in the ``sys.path``.
# This test could potentially pick up other installed distributions
@@ -321,6 +325,7 @@
self.assertEqual(sorted(fake_dists), sorted(found_dists))
+ @requires_zlib
def test_get_distribution(self):
# Test for looking up a distribution by name.
# Test the lookup of the towel-stuff distribution
@@ -371,6 +376,7 @@
self.assertIsInstance(dist, Distribution)
self.assertEqual(dist.name, name)
+ @requires_zlib
def test_provides(self):
# Test for looking up distributions by what they provide
checkLists = lambda x, y: self.assertEqual(sorted(x), sorted(y))
@@ -437,6 +443,7 @@
use_egg_info=True)]
checkLists(l, [])
+ @requires_zlib
def test_obsoletes(self):
# Test looking for distributions based on what they obsolete
checkLists = lambda x, y: self.assertEqual(sorted(x), sorted(y))
@@ -465,6 +472,7 @@
l = [dist.name for dist in obsoletes_distribution('truffles', '0.2')]
checkLists(l, ['towel-stuff'])
+ @requires_zlib
def test_yield_distribution(self):
# tests the internal function _yield_distributions
checkLists = lambda x, y: self.assertEqual(sorted(x), sorted(y))
diff --git a/Lib/packaging/tests/test_depgraph.py b/Lib/packaging/tests/test_depgraph.py
--- a/Lib/packaging/tests/test_depgraph.py
+++ b/Lib/packaging/tests/test_depgraph.py
@@ -7,6 +7,7 @@
from packaging import depgraph
from packaging.tests import unittest, support
+from packaging.tests.support import requires_zlib
class DepGraphTestCase(support.LoggingCatcher,
@@ -56,6 +57,7 @@
self.checkLists([], deps)
self.checkLists(graph.missing[towel], ['bacon (<=0.2)'])
+ @requires_zlib
def test_generate_graph_egg(self):
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG:
@@ -117,6 +119,7 @@
deps = [d.name for d in depgraph.dependent_dists(dists, towel)]
self.checkLists(['choxie'], deps)
+ @requires_zlib
def test_dependent_dists_egg(self):
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG:
@@ -144,6 +147,7 @@
deps = [d.name for d in depgraph.dependent_dists(dists, cheese)]
self.checkLists([], deps)
+ @requires_zlib
def test_graph_to_dot(self):
expected = (
('towel-stuff', 'bacon', 'bacon (<=0.2)'),
@@ -173,6 +177,7 @@
self.checkLists(matches, expected)
+ @requires_zlib
def test_graph_disconnected_to_dot(self):
dependencies_expected = (
('towel-stuff', 'bacon', 'bacon (<=0.2)'),
@@ -234,6 +239,7 @@
self.checkLists(dependencies_matches, dependencies_expected)
self.checkLists(disconnected_matches, disconnected_expected)
+ @requires_zlib
def test_graph_bad_version_to_dot(self):
expected = (
('towel-stuff', 'bacon', 'bacon (<=0.2)'),
@@ -263,6 +269,7 @@
self.checkLists(matches, expected)
+ @requires_zlib
def test_repr(self):
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG + self.BAD_EGGS:
@@ -273,6 +280,7 @@
graph = depgraph.generate_graph(dists)
self.assertTrue(repr(graph))
+ @requires_zlib
def test_main(self):
tempout = io.StringIO()
old = sys.stdout
diff --git a/Lib/packaging/tests/test_pypi_dist.py b/Lib/packaging/tests/test_pypi_dist.py
--- a/Lib/packaging/tests/test_pypi_dist.py
+++ b/Lib/packaging/tests/test_pypi_dist.py
@@ -7,7 +7,7 @@
from packaging.pypi.errors import HashDoesNotMatch, UnsupportedHashName
from packaging.tests import unittest
-from packaging.tests.support import TempdirManager
+from packaging.tests.support import TempdirManager, requires_zlib
from packaging.tests.pypi_server import use_pypi_server
@@ -158,6 +158,7 @@
hashname="invalid_hashname",
hashval="value")
+ @requires_zlib
@use_pypi_server('downloads_with_md5')
def test_unpack(self, server):
url = server.full_address + self.srcpath
diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -28,6 +28,11 @@
except ImportError:
_thread = None
+try:
+ import zlib
+except ImportError:
+ zlib = None
+
__all__ = [
"Error", "TestFailed", "ResourceDenied", "import_module",
"verbose", "use_resources", "max_memuse", "record_original_stdout",
@@ -43,7 +48,7 @@
"threading_cleanup", "reap_children", "cpython_only", "check_impl_detail",
"get_attribute", "swap_item", "swap_attr", "requires_IEEE_754",
"TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
- "import_fresh_module"
+ "import_fresh_module", "requires_zlib"
]
class Error(Exception):
@@ -401,6 +406,8 @@
float.__getformat__("double").startswith("IEEE"),
"test requires IEEE 754 doubles")
+requires_zlib = unittest.skipUnless(zlib, 'requires zlib')
+
is_jython = sys.platform.startswith('java')
# Filename used for testing
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list