summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-09-24 15:05:05 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-09-24 15:05:05 -0400
commit68bcd0a0d496488d179644eebece7f79f3848cb9 (patch)
treead3925dfe0b2e34450dce6e9a1a6aaef8f9cd95b /tests/test_cmd2.py
parent49ab56aae9124b68872ad51fceb0b97c5daa7b38 (diff)
downloadcmd2-git-68bcd0a0d496488d179644eebece7f79f3848cb9.tar.gz
Added unit tests
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 25273b4c..635e7ebd 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1981,6 +1981,23 @@ def test_get_help_topics(base_app):
custom_help = base_app.get_help_topics()
assert len(custom_help) == 0
+def test_get_help_topics_hidden():
+ # Verify get_help_topics() filters out hidden commands
+ class TestApp(cmd2.Cmd):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ def do_my_cmd(self, args):
+ pass
+
+ def help_my_cmd(self, args):
+ pass
+
+ app = TestApp()
+ assert 'my_cmd' in app.get_help_topics()
+
+ app.hidden_commands.append('my_cmd')
+ assert 'my_cmd' not in app.get_help_topics()
class ReplWithExitCode(cmd2.Cmd):
""" Example cmd2 application where we can specify an exit code when existing."""
@@ -2240,6 +2257,10 @@ def test_disable_and_enable_category(disable_commands_app):
assert 'has_helper_funcs' not in visible_commands
assert 'has_no_helper_funcs' not in visible_commands
+ # Make sure get_help_topics() filters out disabled commands
+ help_topics = disable_commands_app.get_help_topics()
+ assert 'has_helper_funcs' not in help_topics
+
##########################################################################
# Enable the category
##########################################################################
@@ -2281,6 +2302,10 @@ def test_disable_and_enable_category(disable_commands_app):
assert 'has_helper_funcs' in visible_commands
assert 'has_no_helper_funcs' in visible_commands
+ # Make sure get_help_topics() contains our help function
+ help_topics = disable_commands_app.get_help_topics()
+ assert 'has_helper_funcs' in help_topics
+
def test_enable_enabled_command(disable_commands_app):
# Test enabling a command that is not disabled
saved_len = len(disable_commands_app.disabled_commands)