[Python-checkins] distutils2: metadata warnings were not shown to the user
tarek.ziade
python-checkins at python.org
Wed Feb 16 22:23:55 CET 2011
tarek.ziade pushed 7bbd7533bc87 to distutils2:
http://hg.python.org/distutils2/rev/7bbd7533bc87
changeset: 995:7bbd7533bc87
parent: 993:6c4e92fdb95e
user: Godefroid Chapelle <gotcha at bubblenet.be>
date: Sun Jan 30 12:28:40 2011 +0100
summary:
metadata warnings were not shown to the user
files:
distutils2/command/check.py
distutils2/tests/test_command_check.py
diff --git a/distutils2/command/check.py b/distutils2/command/check.py
--- a/distutils2/command/check.py
+++ b/distutils2/command/check.py
@@ -56,9 +56,11 @@
Warns if any are missing.
"""
- missing, __ = self.distribution.metadata.check(strict=True)
+ missing, warnings = self.distribution.metadata.check(strict=True)
if missing != []:
self.warn("missing required metadata: %s" % ', '.join(missing))
+ for warning in warnings:
+ self.warn(warning)
def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
diff --git a/distutils2/tests/test_command_check.py b/distutils2/tests/test_command_check.py
--- a/distutils2/tests/test_command_check.py
+++ b/distutils2/tests/test_command_check.py
@@ -48,6 +48,43 @@
cmd = self._run(metadata, strict=1)
self.assertEqual(len(cmd._warnings), 0)
+ def test_check_metadata_1_2(self):
+ # let's run the command with no metadata at all
+ # by default, check is checking the metadata
+ # should have some warnings
+ cmd = self._run()
+ self.assertTrue(len(cmd._warnings) > 0)
+
+ # now let's add the required fields
+ # and run it again, to make sure we don't get
+ # any warning anymore
+ # let's use requires_python as a marker to enforce
+ # Metadata-Version 1.2
+ metadata = {'home_page': 'xxx', 'author': 'xxx',
+ 'author_email': 'xxx',
+ 'name': 'xxx', 'version': 'xxx',
+ 'requires_python': '2.4',
+ }
+ cmd = self._run(metadata)
+ self.assertEqual(len(cmd._warnings), 1)
+
+ # now with the strict mode, we should
+ # get an error if there are missing metadata
+ self.assertRaises(MetadataMissingError, self._run, {}, **{'strict': 1})
+ self.assertRaises(DistutilsSetupError, self._run, {'name':'xxx', 'version':'xxx'}, **{'strict': 1})
+
+ # complain about version format
+ self.assertRaises(DistutilsSetupError, self._run, metadata, **{'strict': 1})
+
+ # now with correct version format
+ metadata = {'home_page': 'xxx', 'author': 'xxx',
+ 'author_email': 'xxx',
+ 'name': 'xxx', 'version': '1.2',
+ 'requires_python': '2.4',
+ }
+ cmd = self._run(metadata, strict=1)
+ self.assertEqual(len(cmd._warnings), 0)
+
@unittest.skipUnless(_HAS_DOCUTILS, "requires docutils")
def test_check_restructuredtext(self):
# let's see if it detects broken rest in long_description
@@ -79,7 +116,7 @@
cmd = check(dist)
cmd.check_hooks_resolvable()
self.assertEqual(len(cmd._warnings), 1)
-
+
def test_suite():
return unittest.makeSuite(CheckTestCase)
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list