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