summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-04 15:22:01 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-04 15:22:01 -0400
commitc233b75147f01e8b34beb8ada6cec3468371c896 (patch)
treeb1f2aa4bddb87b6653188b58265d61c254d4220c
parent4f2d1ba0b1aec77116d660ae8315c74491098a79 (diff)
downloadcmd2-git-c233b75147f01e8b34beb8ada6cec3468371c896.tar.gz
Fixing unit tests
-rwxr-xr-xexamples/subcommands.py6
-rw-r--r--tests/test_completion.py9
2 files changed, 6 insertions, 9 deletions
diff --git a/examples/subcommands.py b/examples/subcommands.py
index d1b7c9db..89bcaf85 100755
--- a/examples/subcommands.py
+++ b/examples/subcommands.py
@@ -33,8 +33,7 @@ bar_subparsers.add_parser('cranberries', help='cranberries help')
# create the parser for the "sport" sub-command
parser_sport = base_subparsers.add_parser('sport', help='sport help')
-sport_arg = parser_sport.add_argument('sport', help='Enter name of a sport')
-setattr(sport_arg, 'arg_choices', sport_item_strs)
+sport_arg = parser_sport.add_argument('sport', help='Enter name of a sport', choices=sport_item_strs)
# create the top-level parser for the alternate command
@@ -60,8 +59,7 @@ bar2_subparsers.add_parser('cranberries', help='cranberries help')
# create the parser for the "sport" sub-command
parser_sport2 = base2_subparsers.add_parser('sport', help='sport help')
-sport2_arg = parser_sport2.add_argument('sport', help='Enter name of a sport')
-setattr(sport2_arg, 'arg_choices', sport_item_strs)
+sport2_arg = parser_sport2.add_argument('sport', help='Enter name of a sport', choices=sport_item_strs)
class SubcommandsExample(cmd2.Cmd):
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 9bf6fc5f..03208a88 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -516,7 +516,7 @@ def test_path_completion_directories_only(cmd2_app, request):
expected = [text + 'cripts' + os.path.sep]
- assert cmd2_app.path_complete(text, line, begidx, endidx, os.path.isdir) == expected
+ assert cmd2_app.path_complete(text, line, begidx, endidx, path_filter=os.path.isdir) == expected
def test_basic_completion_single(cmd2_app):
text = 'Pi'
@@ -592,7 +592,7 @@ def test_flag_based_default_completer(cmd2_app, request):
begidx = endidx - len(text)
assert cmd2_app.flag_based_complete(text, line, begidx, endidx,
- flag_dict, cmd2_app.path_complete) == [text + 'onftest.py']
+ flag_dict, all_else=cmd2_app.path_complete) == [text + 'onftest.py']
def test_flag_based_callable_completer(cmd2_app, request):
test_dir = os.path.dirname(request.module.__file__)
@@ -642,7 +642,7 @@ def test_index_based_default_completer(cmd2_app, request):
begidx = endidx - len(text)
assert cmd2_app.index_based_complete(text, line, begidx, endidx,
- index_dict, cmd2_app.path_complete) == [text + 'onftest.py']
+ index_dict, all_else=cmd2_app.path_complete) == [text + 'onftest.py']
def test_index_based_callable_completer(cmd2_app, request):
test_dir = os.path.dirname(request.module.__file__)
@@ -1072,8 +1072,7 @@ class SubcommandsWithUnknownExample(cmd2.Cmd):
# create the parser for the "sport" sub-command
parser_sport = base_subparsers.add_parser('sport', help='sport help')
- sport_arg = parser_sport.add_argument('sport', help='Enter name of a sport')
- setattr(sport_arg, 'arg_choices', sport_item_strs)
+ sport_arg = parser_sport.add_argument('sport', help='Enter name of a sport', choices=sport_item_strs)
@cmd2.with_argparser_and_unknown_args(base_parser)
def do_base(self, args):