Rev 5222: ``bzrlib.commands.Command`` will now raise ValueError during in http://bazaar.launchpad.net/~lifeless/bzr/command-help-bug-177500
Robert Collins
robertc at robertcollins.net
Tue May 11 12:05:58 BST 2010
At http://bazaar.launchpad.net/~lifeless/bzr/command-help-bug-177500
------------------------------------------------------------
revno: 5222
revision-id: robertc at robertcollins.net-20100511110549-u2hzal40x29ljuhh
parent: pqm at pqm.ubuntu.com-20100510184319-3mbzqg9cueihvpsw
committer: Robert Collins <robertc at robertcollins.net>
branch nick: command-help-bug-177500
timestamp: Tue 2010-05-11 23:05:49 +1200
message:
``bzrlib.commands.Command`` will now raise ValueError during
construction if there is no __doc__ set. (Robert Collins)
=== modified file 'NEWS'
--- a/NEWS 2010-05-10 18:43:19 +0000
+++ b/NEWS 2010-05-11 11:05:49 +0000
@@ -18,6 +18,9 @@
whoami``.
(Parth Malwankar, #549310)
+* ``bzrlib.commands.Command`` will now raise ValueError during
+ construction if there is no __doc__ set. (Robert Collins)
+
New Features
************
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2010-04-28 13:03:47 +0000
+++ b/bzrlib/commands.py 2010-05-11 11:05:49 +0000
@@ -407,8 +407,8 @@
def __init__(self):
"""Construct an instance of this command."""
- if self.__doc__ == Command.__doc__:
- warn("No help message set for %r" % self)
+ if self.__doc__ == Command.__doc__ or not self.__doc__:
+ raise ValueError("No help message set for %r" % self)
# List of standard options directly supported
self.supported_std_options = []
self._setup_run()
@@ -483,7 +483,9 @@
"""
doc = self.help()
if doc is None:
- raise NotImplementedError("sorry, no detailed help yet for %r" % self.name())
+ raise NotImplementedError(
+ "self.help() returned None - no detailed help yet for %r" %
+ self.name())
# Extract the summary (purpose) and sections out from the text
purpose,sections,order = self._get_help_parts(doc)
=== modified file 'bzrlib/tests/test_commands.py'
--- a/bzrlib/tests/test_commands.py 2010-04-22 18:36:13 +0000
+++ b/bzrlib/tests/test_commands.py 2010-05-11 11:05:49 +0000
@@ -79,6 +79,11 @@
c = self.get_command([option.Option('foo', hidden=False)])
self.assertContainsRe(c.get_help_text(), '--foo')
+ def test_no_help_init_failure(self):
+ class cmd_foo(commands.Command):
+ pass
+ self.assertRaises(ValueError, cmd_foo)
+
class TestGetAlias(tests.TestCase):
More information about the bazaar-commits
mailing list