summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-23 16:23:49 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-23 16:23:49 -0400
commit966d6a53e87147e2db9424c0f0060ca7e20e690f (patch)
tree26948ca1fbaa409d6731b27fb0f6982333c424ba /tests
parent747028ddd9640ab054200d00d1a1bb13ea7bd704 (diff)
downloadcmd2-git-966d6a53e87147e2db9424c0f0060ca7e20e690f.tar.gz
Fixed check for whether a subcommand was entered
Diffstat (limited to 'tests')
-rw-r--r--tests/test_completion.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 35d014cd..daeb94bf 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -723,10 +723,11 @@ class SubcommandsExample(cmd2.Cmd):
@cmd2.with_argparser(base_parser)
def do_base(self, args):
"""Base command help"""
- try:
- # Call whatever sub-command function was selected
- args.func(self, args)
- except AttributeError:
+ func = getattr(args, 'func', None)
+ if func is not None:
+ # Call whatever subcommand function was selected
+ func(self, args)
+ else:
# No sub-command was provided, so as called
self.do_help('base')