Skip to content

Commit e1dc763

Browse files
committed
Updated unit test
1 parent d80b27f commit e1dc763

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cmd2/cmd2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ def complete(self, text: str, state: int) -> Optional[str]:
14191419
except CompletionError as e:
14201420
err_str = str(e)
14211421
if err_str:
1422+
# Don't print error and redraw the prompt unless the error has length
14221423
ansi.style_aware_write(sys.stdout, err_str + '\n')
14231424
rl_force_redisplay()
14241425
return None

tests/test_argparse_completer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def test_completion_items_default_header(ac_app):
699699
('hint', '', True),
700700
('hint --flag', '', True),
701701
('hint --suppressed_help', '', False),
702-
('hint --suppressed_hint', '--', False),
702+
('hint --suppressed_hint', '', False),
703703
704704
# Hint because flag does not have enough values to be considered finished
705705
('nargs --one_or_more', '-', True),
@@ -730,7 +730,10 @@ def test_autocomp_hint(ac_app, command_and_args, text, has_hint, capsys):
730730

731731
complete_tester(text, line, begidx, endidx, ac_app)
732732
out, err = capsys.readouterr()
733-
assert has_hint == ("Hint:\n" in out)
733+
if has_hint:
734+
assert "Hint:\n" in out
735+
else:
736+
assert not out
734737

735738

736739
def test_autocomp_hint_no_help_text(ac_app, capsys):

0 commit comments

Comments
 (0)