aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/cmdutil.py
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2005-03-11 21:49:42 +0000
committerAaron Bentley <abentley@panoramicfeedback.com>2005-03-11 21:49:42 +0000
commit71597577918f8d8206256293a7c985bc800a1363 (patch)
tree114799cc2b992f63c3b3bc12ed7526e9a7a145dd /libbe/cmdutil.py
parent6d32caa83004a2b3571754ddde5a389bac38423d (diff)
downloadbugseverywhere-71597577918f8d8206256293a7c985bc800a1363.tar.gz
Added unit testing framework
Diffstat (limited to 'libbe/cmdutil.py')
-rw-r--r--libbe/cmdutil.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index 891e273..3fbfb50 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -55,6 +55,17 @@ def iter_commands():
yield name.replace("_", "-"), module
def get_command(command_name):
+ """Retrieves the module for a user command
+
+ >>> get_command("asdf")
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ File "/home/abentley/be/libbe/cmdutil.py", line 60, in get_command
+ raise UserError("Unknown command %s" % command_name)
+ UserError: Unknown command asdf
+ >>> get_command("list")
+ <module 'becommands.list' from '/home/abentley/be/becommands/list.pyc'>
+ """
cmd = plugin.get_plugin("becommands", command_name.replace("-", "_"))
if cmd is None:
raise UserError("Unknown command %s" % command_name)
@@ -65,3 +76,11 @@ def execute(cmd, args):
def help(cmd, args):
return get_command(cmd).help()
+
+def _test():
+ import doctest
+ import sys
+ doctest.testmod()
+
+if __name__ == "__main__":
+ _test()