summaryrefslogtreecommitdiff
path: root/distutils2/tests/test_command_check.py
diff options
context:
space:
mode:
authorAlexis Metaireau <ametaireau@gmail.com>2010-10-04 02:41:02 +0100
committerAlexis Metaireau <ametaireau@gmail.com>2010-10-04 02:41:02 +0100
commit89d3d9d57e7ba2e3204312f868bcb4796929f315 (patch)
tree742d225307175c814ddbc632fcd1da19ca58a65b /distutils2/tests/test_command_check.py
parent47658d6c3a2d438c7f4e0de7471bb422b1610ca6 (diff)
downloaddisutils2-89d3d9d57e7ba2e3204312f868bcb4796929f315.tar.gz
Rename command's tests filenames to test_command_*, and install_tools.py to install.py
The goal is to avoid overlaps between commands and scripts names (for instance the "install" script and the "install" command)
Diffstat (limited to 'distutils2/tests/test_command_check.py')
-rw-r--r--distutils2/tests/test_command_check.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/distutils2/tests/test_command_check.py b/distutils2/tests/test_command_check.py
new file mode 100644
index 0000000..93da1f2
--- /dev/null
+++ b/distutils2/tests/test_command_check.py
@@ -0,0 +1,84 @@
+"""Tests for distutils.command.check."""
+
+from distutils2.command.check import check
+from distutils2.metadata import _HAS_DOCUTILS
+from distutils2.tests import unittest, support
+from distutils2.errors import DistutilsSetupError
+
+class CheckTestCase(support.LoggingCatcher,
+ support.TempdirManager,
+ unittest.TestCase):
+
+ def _run(self, metadata=None, **options):
+ if metadata is None:
+ metadata = {}
+ pkg_info, dist = self.create_dist(**metadata)
+ cmd = check(dist)
+ cmd.initialize_options()
+ for name, value in options.items():
+ setattr(cmd, name, value)
+ cmd.ensure_finalized()
+ cmd.run()
+ return cmd
+
+ def test_check_metadata(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
+ metadata = {'home_page': 'xxx', 'author': 'xxx',
+ 'author_email': '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})
+
+ # and of course, no error when all metadata fields are present
+ 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
+ broken_rest = 'title\n===\n\ntest'
+ pkg_info, dist = self.create_dist(description=broken_rest)
+ cmd = check(dist)
+ cmd.check_restructuredtext()
+ self.assertEqual(len(cmd._warnings), 1)
+
+ pkg_info, dist = self.create_dist(description='title\n=====\n\ntest')
+ cmd = check(dist)
+ cmd.check_restructuredtext()
+ self.assertEqual(len(cmd._warnings), 0)
+
+ def test_check_all(self):
+
+ metadata = {'home_page': 'xxx', 'author': 'xxx'}
+ self.assertRaises(DistutilsSetupError, self._run,
+ {}, **{'strict': 1,
+ 'all': 1})
+
+ def test_check_hooks(self):
+ pkg_info, dist = self.create_dist()
+ dist.command_options['install'] = {
+ 'pre_hook': ('file', {"a": 'some.nonextistant.hook.ghrrraarrhll'}),
+ }
+ cmd = check(dist)
+ cmd.check_hooks_resolvable()
+ self.assertEqual(len(cmd._warnings), 1)
+
+
+def test_suite():
+ return unittest.makeSuite(CheckTestCase)
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")