[Python-checkins] distutils2: Switch from docstrings to comments in tests, to uniformize output.
tarek.ziade
python-checkins at python.org
Thu Jul 15 01:38:05 CEST 2010
tarek.ziade pushed d7db403b144a to distutils2:
http://hg.python.org/distutils2/rev/d7db403b144a
changeset: 356:d7db403b144a
user: Alexis Metaireau <ametaireau at gmail.com>
date: Wed Jul 07 04:35:06 2010 +0200
summary: Switch from docstrings to comments in tests, to uniformize output.
files: src/distutils2/_backport/tests/test_pkgutil.py, src/distutils2/_backport/tests/test_sysconfig.py, src/distutils2/tests/test_pypi_dist.py, src/distutils2/tests/test_pypi_server.py, src/distutils2/tests/test_pypi_simple.py
diff --git a/src/distutils2/_backport/tests/test_pkgutil.py b/src/distutils2/_backport/tests/test_pkgutil.py
--- a/src/distutils2/_backport/tests/test_pkgutil.py
+++ b/src/distutils2/_backport/tests/test_pkgutil.py
@@ -26,7 +26,7 @@
from unittest2.compatibility import relpath
# TODO Add a test for getting a distribution that is provided by another
-# distribution.
+# distribution.
# TODO Add a test for absolute pathed RECORD items (e.g. /etc/myapp/config.ini)
@@ -143,7 +143,7 @@
class TestPkgUtilDistribution(unittest.TestCase):
- """Tests the pkgutil.Distribution class"""
+ # Tests the pkgutil.Distribution class
def setUp(self):
self.fake_dists_path = os.path.abspath(
@@ -196,8 +196,8 @@
open(record_file, 'w').close()
def test_instantiation(self):
- """Test the Distribution class's instantiation provides us with usable
- attributes."""
+ # Test the Distribution class's instantiation provides us with usable
+ # attributes.
# Import the Distribution class
from distutils2._backport.pkgutil import distinfo_dirname, Distribution
@@ -215,7 +215,7 @@
self.assertTrue(isinstance(dist.requested, type(bool())))
def test_installed_files(self):
- """Test the iteration of installed files."""
+ # Test the iteration of installed files.
# Test the distribution's installed files
from distutils2._backport.pkgutil import Distribution
for distinfo_dir in self.distinfo_dirs:
@@ -227,7 +227,7 @@
self.assertEqual(size, record_data[path][1])
def test_uses(self):
- """Test to determine if a distribution uses a specified file."""
+ # Test to determine if a distribution uses a specified file.
# Criteria to test against
distinfo_name = 'grammar-1.0a4'
distinfo_dir = os.path.join(self.fake_dists_path,
@@ -246,7 +246,7 @@
self.assertFalse(dist.uses(false_path))
def test_get_distinfo_file(self):
- """Test the retrieval of dist-info file objects."""
+ # Test the retrieval of dist-info file objects.
from distutils2._backport.pkgutil import Distribution
distinfo_name = 'choxie-2.0.0.9'
other_distinfo_name = 'grammar-1.0a4'
@@ -279,7 +279,7 @@
'ENTRYPOINTS')
def test_get_distinfo_files(self):
- """Test for the iteration of RECORD path entries."""
+ # Test for the iteration of RECORD path entries.
from distutils2._backport.pkgutil import Distribution
distinfo_name = 'towel_stuff-0.1'
distinfo_dir = os.path.join(self.fake_dists_path,
@@ -297,7 +297,7 @@
class TestPkgUtilPEP376(unittest.TestCase):
- """Tests for the new functionality added in PEP 376."""
+ # Tests for the new functionality added in PEP 376.
def setUp(self):
# Setup the path environment with our fake distributions
@@ -310,15 +310,15 @@
sys.path[:] = self.sys_path
def test_distinfo_dirname(self):
- """Given a name and a version, we expect the distinfo_dirname function
- to return a standard distribution information directory name."""
+ # Given a name and a version, we expect the distinfo_dirname function
+ # to return a standard distribution information directory name.
items = [# (name, version, standard_dirname)
# Test for a very simple single word name and decimal
# version number
('docutils', '0.5', 'docutils-0.5.dist-info'),
# Test for another except this time with a '-' in the name, which
- # needs to be transformed during the name lookup
+ # needs to be transformed during the name lookup
('python-ldap', '2.5', 'python_ldap-2.5.dist-info'),
# Test for both '-' in the name and a funky version number
('python-ldap', '2.5 a---5', 'python_ldap-2.5 a---5.dist-info'),
@@ -333,7 +333,7 @@
self.assertEqual(dirname, standard_dirname)
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
fake_dists = [('grammar', '1.0a4'), ('choxie', '2.0.0.9'),
('towel-stuff', '0.1')]
@@ -374,7 +374,7 @@
self.assertListEqual(sorted(fake_dists), sorted(found_dists))
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
name = 'towel-stuff' # Note: This is different from the directory name
@@ -420,7 +420,7 @@
self.assertEqual(dist.name, 'strawberry')
def test_get_file_users(self):
- """Test the iteration of distributions that use a file."""
+ # Test the iteration of distributions that use a file.
from distutils2._backport.pkgutil import get_file_users, Distribution
name = 'towel_stuff-0.1'
path = os.path.join(self.fake_dists_path, name,
@@ -430,7 +430,7 @@
self.assertEqual(dist.name, name)
def test_provides(self):
- """ Test for looking up distributions by what they provide """
+ # Test for looking up distributions by what they provide
from distutils2._backport.pkgutil import provides_distribution
from distutils2.errors import DistutilsError
@@ -502,7 +502,7 @@
checkLists(l, [])
def test_obsoletes(self):
- """ Test looking for distributions based on what they obsolete """
+ # Test looking for distributions based on what they obsolete
from distutils2._backport.pkgutil import obsoletes_distribution
from distutils2.errors import DistutilsError
diff --git a/src/distutils2/_backport/tests/test_sysconfig.py b/src/distutils2/_backport/tests/test_sysconfig.py
--- a/src/distutils2/_backport/tests/test_sysconfig.py
+++ b/src/distutils2/_backport/tests/test_sysconfig.py
@@ -88,15 +88,13 @@
shutil.rmtree(path)
def test_nested_var_substitution(self):
- """Assert that the {curly brace token} expansion pattern will replace
- only the inner {something} on nested expressions like {py{something}} on
- the first pass.
+ # Assert that the {curly brace token} expansion pattern will replace
+ # only the inner {something} on nested expressions like {py{something}} on
+ # the first pass.
- We have no plans to make use of this, but it keeps the option open for
- the future, at the cost only of disallowing { itself as a piece of a
- substitution key (which would be weird).
-
- """
+ # We have no plans to make use of this, but it keeps the option open for
+ # the future, at the cost only of disallowing { itself as a piece of a
+ # substitution key (which would be weird).
self.assertEqual(_subst_vars('{py{version}}', {'version': '31'}), '{py31}')
def test_get_paths(self):
diff --git a/src/distutils2/tests/test_pypi_dist.py b/src/distutils2/tests/test_pypi_dist.py
--- a/src/distutils2/tests/test_pypi_dist.py
+++ b/src/distutils2/tests/test_pypi_dist.py
@@ -16,17 +16,17 @@
class TestPyPIDistribution(support.TempdirManager,
unittest.TestCase):
- """tests the pypi.dist.PyPIDistribution class"""
+ """Tests the pypi.dist.PyPIDistribution class"""
def test_instanciation(self):
- """Test the Distribution class provides us the good attributes when
- given on construction"""
+ # Test the Distribution class provides us the good attributes when
+ # given on construction
dist = Dist("FooBar", "1.1")
self.assertEqual("FooBar", dist.name)
self.assertEqual("1.1", "%s" % dist.version)
def test_create_from_url(self):
- """Test that the Distribution object can be built from a single URL"""
+ # Test that the Distribution object can be built from a single URL
url_list = {
'FooBar-1.1.0.tar.gz': {
'name': 'foobar', # lowercase the name
@@ -68,7 +68,7 @@
self.assertEqual(getattr(dist, attribute), value)
def test_get_url(self):
- """Test that the url property works well"""
+ # Test that the url property works well
d = Dist("foobar", "1.1", url="test_url")
self.assertDictEqual(d.url, {
@@ -90,7 +90,7 @@
self.assertEqual(2, len(d._urls))
def test_comparaison(self):
- """Test that we can compare PyPIDistributions"""
+ # Test that we can compare PyPIDistributions
foo1 = Dist("foo", "1.0")
foo2 = Dist("foo", "2.0")
bar = Dist("bar", "2.0")
@@ -103,7 +103,7 @@
self.assertRaises(TypeError, foo1.__eq__, bar)
def test_split_archive_name(self):
- """Test we can split the archive names"""
+ # Test we can split the archive names
names = {
'foo-bar-baz-1.0-rc2': ('foo-bar-baz', '1.0c2'),
'foo-bar-baz-1.0': ('foo-bar-baz', '1.0'),
@@ -114,7 +114,7 @@
@use_pypi_server("downloads_with_md5")
def test_download(self, server):
- """Download is possible, and the md5 is checked if given"""
+ # Download is possible, and the md5 is checked if given
url = "%s/simple/foobar/foobar-0.1.tar.gz" % server.full_address
# check md5 if given
@@ -146,8 +146,7 @@
shutil.rmtree(os.path.dirname(path2))
def test_hashname(self):
- """Invalid hashnames raises an exception on assignation"""
- # should be ok
+ # Invalid hashnames raises an exception on assignation
Dist("FooBar", "0.1", url_hashname="md5", url_hashval="value")
self.assertRaises(UnsupportedHashName, Dist, "FooBar", "0.1",
@@ -155,11 +154,10 @@
class TestPyPIDistributions(unittest.TestCase):
- """test the pypi.distr.PyPIDistributions class"""
def test_filter(self):
- """Test we filter the distributions the right way, using version
- predicate match method"""
+ # Test we filter the distributions the right way, using version
+ # predicate match method
dists = Dists((
Dist("FooBar", "1.1"),
Dist("FooBar", "1.1.1"),
@@ -173,7 +171,6 @@
self.assertIn(dists[1], filtered)
def test_append(self):
- """Test the append method of PyPIDistributions"""
# When adding a new item to the list, the behavior is to test if
# a distribution with the same name and version number already exists,
# and if so, to add url informations to the existing PyPIDistribution
@@ -198,7 +195,7 @@
self.assertEqual(3, len(dists))
def test_prefer_final(self):
- """Ordering support prefer_final"""
+ # Can order the distributions using prefer_final
fb10 = Dist("FooBar", "1.0") # final distribution
fb11a = Dist("FooBar", "1.1a1") # alpha
@@ -213,7 +210,7 @@
self.assertEqual(fb12b, dists[0])
def test_prefer_source(self):
- """Ordering support prefer_source"""
+ # Ordering support prefer_source
fb_source = Dist("FooBar", "1.0", type="source")
fb_binary = Dist("FooBar", "1.0", type="binary")
fb2_binary = Dist("FooBar", "2.0", type="binary")
@@ -230,8 +227,7 @@
self.assertEqual(fb2_binary, dists[0])
def test_get_same_name_and_version(self):
- """PyPIDistributions can return a list of "duplicates"
- """
+ # PyPIDistributions can return a list of "duplicates"
fb_source = Dist("FooBar", "1.0", type="source")
fb_binary = Dist("FooBar", "1.0", type="binary")
fb2_binary = Dist("FooBar", "2.0", type="binary")
diff --git a/src/distutils2/tests/test_pypi_server.py b/src/distutils2/tests/test_pypi_server.py
--- a/src/distutils2/tests/test_pypi_server.py
+++ b/src/distutils2/tests/test_pypi_server.py
@@ -10,7 +10,7 @@
class PyPIServerTest(unittest.TestCase):
def test_records_requests(self):
- """We expect that PyPIServer can log our requests"""
+ # We expect that PyPIServer can log our requests
server = PyPIServer()
server.start()
self.assertEqual(len(server.requests), 0)
@@ -29,8 +29,7 @@
server.stop()
def test_serve_static_content(self):
- """PYPI Mocked server can serve static content from disk.
- """
+ # PYPI Mocked server can serve static content from disk.
def uses_local_files_for(server, url_path):
"""Test that files are served statically (eg. the output from the
diff --git a/src/distutils2/tests/test_pypi_simple.py b/src/distutils2/tests/test_pypi_simple.py
--- a/src/distutils2/tests/test_pypi_simple.py
+++ b/src/distutils2/tests/test_pypi_simple.py
@@ -20,7 +20,7 @@
unittest.TestCase):
def _get_simple_index(self, server, base_url="/simple/", hosts=None,
- *args, **kwargs):
+ *args, **kwargs):
"""Build and return a SimpleSimpleIndex instance, with the test server
urls
"""
@@ -43,9 +43,7 @@
# issue 16
# easy_install inquant.contentmirror.plone breaks because of a typo
# in its home URL
- index = simple.SimpleIndex(
- hosts=('www.example.com',))
-
+ index = simple.SimpleIndex(hosts=('www.example.com',))
url = 'url:%20https://svn.plone.org/svn/collective/inquant.contentmirror.plone/trunk'
try:
v = index._open_url(url)
@@ -88,8 +86,7 @@
@use_pypi_server("test_found_links")
def test_found_links(self, server):
- """Browse the index, asking for a specified distribution version
- """
+ # Browse the index, asking for a specified distribution version
# The PyPI index contains links for version 1.0, 1.1, 2.0 and 2.0.1
index = self._get_simple_index(server)
last_distribution = index.get("foobar")
@@ -143,8 +140,7 @@
@use_pypi_server("with_externals")
def test_restrict_hosts(self, server):
- """Include external pages
- """
+ # Include external pages
# Try to request the package index, wich contains links to "externals"
# resources. They have to be scanned too.
index = self._get_simple_index(server, follow_externals=True)
@@ -154,8 +150,7 @@
@use_pypi_server("with_real_externals")
def test_restrict_hosts(self, server):
- """Only use a list of allowed hosts is possible
- """
+ # Only use a list of allowed hosts is possible
# Test that telling the simple pyPI client to not retrieve external
# works
index = self._get_simple_index(server, follow_externals=False)
@@ -163,28 +158,22 @@
self.assertNotIn(server.full_address + "/external/external.html",
index._processed_urls)
- @use_pypi_server("with_egg_files")
- def test_scan_egg_files(self, server):
- """Assert that egg files are indexed as well"""
- pass
-
@use_pypi_server(static_filesystem_paths=["with_externals"],
static_uri_paths=["simple", "external"])
def test_links_priority(self, server):
- """
- Download links from the pypi simple index should be used before
- external download links.
- http://bitbucket.org/tarek/distribute/issue/163/md5-validation-error
+ # Download links from the pypi simple index should be used before
+ # external download links.
+ # http://bitbucket.org/tarek/distribute/issue/163/md5-validation-error
+ #
+ # Usecase :
+ # - someone uploads a package on pypi, a md5 is generated
+ # - someone manually coindexes this link (with the md5 in the url) onto
+ # an external page accessible from the package page.
+ # - someone reuploads the package (with a different md5)
+ # - while easy_installing, an MD5 error occurs because the external link
+ # is used
+ # -> The index should use the link from pypi, not the external one.
- Usecase :
- - someone uploads a package on pypi, a md5 is generated
- - someone manually coindexes this link (with the md5 in the url) onto
- an external page accessible from the package page.
- - someone reuploads the package (with a different md5)
- - while easy_installing, an MD5 error occurs because the external link
- is used
- -> The index should use the link from pypi, not the external one.
- """
# start an index server
index_url = server.full_address + '/simple/'
@@ -202,10 +191,10 @@
@use_pypi_server(static_filesystem_paths=["with_norel_links"],
static_uri_paths=["simple", "external"])
def test_not_scan_all_links(self, server):
- """Do not follow all index page links.
- The links not tagged with rel="download" and rel="homepage" have
- to not be processed by the package index, while processing "pages".
- """
+ # Do not follow all index page links.
+ # The links not tagged with rel="download" and rel="homepage" have
+ # to not be processed by the package index, while processing "pages".
+
# process the pages
index = self._get_simple_index(server, follow_externals=True)
index.find("foobar")
@@ -225,7 +214,7 @@
index._processed_urls) # linked from external homepage (rel)
def test_uses_mirrors(self):
- """When the main repository seems down, try using the given mirrors"""
+ # When the main repository seems down, try using the given mirrors"""
server = PyPIServer("foo_bar_baz")
mirror = PyPIServer("foo_bar_baz")
mirror.start() # we dont start the server here
@@ -242,7 +231,7 @@
mirror.stop()
def test_simple_link_matcher(self):
- """Test that the simple link matcher yields the right links"""
+ # Test that the simple link matcher yields the right links"""
index = simple.SimpleIndex(follow_externals=False)
# Here, we define:
@@ -276,7 +265,7 @@
self.assertRaises(StopIteration, generator.next)
def test_browse_local_files(self):
- """Test that we can browse local files"""
+ # Test that we can browse local files"""
index_path = os.sep.join(["file://" + PYPI_DEFAULT_STATIC_PATH,
"test_found_links", "simple"])
index = simple.SimpleIndex(index_path)
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list