Skip to content

Commit 47999ff

Browse files
committed
Improved code coverage
1 parent ee15a3d commit 47999ff

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

examples/tab_autocomp_dynamic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self):
6969
setattr(director_action, argparse_completer.ACTION_ARG_CHOICES, TabCompleteExample.static_list_directors)
7070
setattr(actor_action, argparse_completer.ACTION_ARG_CHOICES, 'instance_query_actors')
7171

72-
# tag the file property with a custom completion function 'delimeter_complete' provided by cmd2.
72+
# tag the file property with a custom completion function 'delimiter_complete' provided by cmd2.
7373
setattr(vid_movie_file_action, argparse_completer.ACTION_ARG_CHOICES,
7474
('delimiter_complete',
7575
{'delimiter': '/',

examples/tab_autocompletion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def _do_vid_media_shows(self, args) -> None:
255255
setattr(director_action, argparse_completer.ACTION_ARG_CHOICES, static_list_directors)
256256
setattr(actor_action, argparse_completer.ACTION_ARG_CHOICES, 'instance_query_actors')
257257

258-
# tag the file property with a custom completion function 'delimeter_complete' provided by cmd2.
258+
# tag the file property with a custom completion function 'delimiter_complete' provided by cmd2.
259259
setattr(vid_movie_file_action, argparse_completer.ACTION_ARG_CHOICES,
260260
('delimiter_complete',
261261
{'delimiter': '/',

tests/test_autocompletion.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def test_autocomp_subcmd_flag_comp_list_attr(cmd2_app):
229229
assert first_match is not None and first_match == '"Gareth Edwards'
230230

231231

232-
def test_autcomp_pos_consumed(cmd2_app):
232+
def test_autocomp_pos_consumed(cmd2_app):
233233
text = ''
234234
line = 'library movie add SW_EP01 {}'.format(text)
235235
endidx = len(line)
@@ -239,7 +239,7 @@ def test_autcomp_pos_consumed(cmd2_app):
239239
assert first_match is None
240240

241241

242-
def test_autcomp_pos_after_flag(cmd2_app):
242+
def test_autocomp_pos_after_flag(cmd2_app):
243243
text = 'Joh'
244244
line = 'video movies add -d "George Lucas" -- "Han Solo" PG "Emilia Clarke" "{}'.format(text)
245245
endidx = len(line)
@@ -250,7 +250,7 @@ def test_autcomp_pos_after_flag(cmd2_app):
250250
cmd2_app.completion_matches == ['John Boyega" ']
251251

252252

253-
def test_autcomp_custom_func_list_arg(cmd2_app):
253+
def test_autocomp_custom_func_list_arg(cmd2_app):
254254
text = 'SW_'
255255
line = 'library show add {}'.format(text)
256256
endidx = len(line)
@@ -261,7 +261,7 @@ def test_autcomp_custom_func_list_arg(cmd2_app):
261261
cmd2_app.completion_matches == ['SW_CW', 'SW_REB', 'SW_TCW']
262262

263263

264-
def test_autcomp_custom_func_list_and_dict_arg(cmd2_app):
264+
def test_autocomp_custom_func_list_and_dict_arg(cmd2_app):
265265
text = ''
266266
line = 'library show add SW_REB {}'.format(text)
267267
endidx = len(line)
@@ -272,6 +272,17 @@ def test_autcomp_custom_func_list_and_dict_arg(cmd2_app):
272272
cmd2_app.completion_matches == ['S01E02', 'S01E03', 'S02E01', 'S02E03']
273273

274274

275+
def test_autocomp_custom_func_dict_arg(cmd2_app):
276+
text = '/home/user/'
277+
line = 'video movies load {}'.format(text)
278+
endidx = len(line)
279+
begidx = endidx - len(text)
280+
281+
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
282+
assert first_match is not None and \
283+
cmd2_app.completion_matches == ['/home/user/another.db', '/home/user/file space.db', '/home/user/file.db']
284+
285+
275286
def test_argparse_remainder_flag_completion(cmd2_app):
276287
import cmd2
277288
import argparse

0 commit comments

Comments
 (0)