Rev 5224: (lifeless) Fail to construct commands that have no help, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue May 11 16:04:06 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5224 [merge]
revision-id: pqm at pqm.ubuntu.com-20100511150400-7euir3548ln55n7s
parent: pqm at pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
parent: robertc at robertcollins.net-20100511110549-u2hzal40x29ljuhh
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-05-11 16:04:00 +0100
message:
(lifeless) Fail to construct commands that have no help,
rather than failing when help is first requested. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/tests/test_commands.py test_command.py-20051019190109-3b17be0f52eaa7a8
=== modified file 'NEWS'
--- a/NEWS 2010-05-11 08:44:59 +0000
+++ b/NEWS 2010-05-11 15:04:00 +0000
@@ -26,6 +26,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