diff options
author | Eric Lin <anselor@gmail.com> | 2018-04-11 15:11:52 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2018-04-11 15:11:52 -0400 |
commit | 33decb449c61e2a78877563309929c4686ea081e (patch) | |
tree | 85ce1f9b2b893f9daee08b7c61d098bd0752ed2b /tests/test_cmd2.py | |
parent | 52bf16c412eb7933eac159ed0fc6363ccc37a82c (diff) | |
download | cmd2-git-33decb449c61e2a78877563309929c4686ea081e.tar.gz |
Added a with_category decorator that can be used to tag a command category.
Changed the detection of with_argparse decorated commands to be less hacky/brittle.
Now it tags the function with help_summary.
Fixed issue with handling commands that provide a custom help_ function. We can now
redirect the output to a string to be formatted with the other commands.
Added some documentation explaining the new help categories.
Updated unit tests.
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r-- | tests/test_cmd2.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 0861c073..75d27869 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -55,7 +55,7 @@ def test_base_argparse_help(base_app, capsys): # Verify that "set -h" gives the same output as "help set" and that it starts in a way that makes sense run_cmd(base_app, 'set -h') out, err = capsys.readouterr() - out1 = normalize(out) + out1 = normalize(str(out)) out2 = run_cmd(base_app, 'help set') @@ -1080,12 +1080,11 @@ class HelpCategoriesApp(cmd2.Cmd): # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x cmd2.Cmd.__init__(self, *args, **kwargs) + @cmd2.with_category('Some Category') def do_diddly(self, arg): """This command does diddly""" pass - cmd2.categorize(do_diddly, "Some Category") - def do_squat(self, arg): """This docstring help will never be shown because the help_squat method overrides it.""" pass @@ -1138,7 +1137,7 @@ def test_help_cat_verbose(helpcat_app): Custom Category ================================================================================ edit This overrides the edit command and does nothing. -squat This docstring help will never be shown because the help_squat method overrides it. +squat This command does diddly squat... Some Category ================================================================================ |