From 71597577918f8d8206256293a7c985bc800a1363 Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Fri, 11 Mar 2005 21:49:42 +0000 Subject: Added unit testing framework --- libbe/cmdutil.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libbe/cmdutil.py') 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 "", 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") + + """ 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() -- cgit