summaryrefslogtreecommitdiff
path: root/distutils2/tests/test_command_check.py
diff options
context:
space:
mode:
Diffstat (limited to 'distutils2/tests/test_command_check.py')
-rw-r--r--distutils2/tests/test_command_check.py55
1 files changed, 50 insertions, 5 deletions
diff --git a/distutils2/tests/test_command_check.py b/distutils2/tests/test_command_check.py
index 60ed4cb..ec41c9e 100644
--- a/distutils2/tests/test_command_check.py
+++ b/distutils2/tests/test_command_check.py
@@ -4,6 +4,8 @@ from distutils2.command.check import check
from distutils2.metadata import _HAS_DOCUTILS
from distutils2.tests import unittest, support
from distutils2.errors import DistutilsSetupError
+from distutils2.errors import MetadataMissingError
+
class CheckTestCase(support.LoggingCatcher,
support.TempdirManager,
@@ -11,7 +13,7 @@ class CheckTestCase(support.LoggingCatcher,
def _run(self, metadata=None, **options):
if metadata is None:
- metadata = {}
+ metadata = {'name': 'xxx', 'version': 'xxx'}
pkg_info, dist = self.create_dist(**metadata)
cmd = check(dist)
cmd.initialize_options()
@@ -33,19 +35,60 @@ class CheckTestCase(support.LoggingCatcher,
# any warning anymore
metadata = {'home_page': 'xxx', 'author': 'xxx',
'author_email': 'xxx',
- 'name': 'xxx', 'version': 'xxx'
+ 'name': 'xxx', 'version': 'xxx',
}
cmd = self._run(metadata)
self.assertEqual(len(cmd._warnings), 0)
# now with the strict mode, we should
# get an error if there are missing metadata
- self.assertRaises(DistutilsSetupError, self._run, {}, **{'strict': 1})
+ self.assertRaises(MetadataMissingError, self._run, {}, **{'strict': 1})
+ self.assertRaises(DistutilsSetupError, self._run,
+ {'name': 'xxx', 'version': 'xxx'}, **{'strict': 1})
# and of course, no error when all metadata fields are present
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
@@ -62,8 +105,10 @@ class CheckTestCase(support.LoggingCatcher,
def test_check_all(self):
- metadata = {'home_page': 'xxx', 'author': 'xxx'}
self.assertRaises(DistutilsSetupError, self._run,
+ {'name': 'xxx', 'version': 'xxx'}, **{'strict': 1,
+ 'all': 1})
+ self.assertRaises(MetadataMissingError, self._run,
{}, **{'strict': 1,
'all': 1})
@@ -75,7 +120,7 @@ class CheckTestCase(support.LoggingCatcher,
cmd = check(dist)
cmd.check_hooks_resolvable()
self.assertEqual(len(cmd._warnings), 1)
-
+
def test_suite():
return unittest.makeSuite(CheckTestCase)