summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index c9a41033..6353d884 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -21,6 +21,7 @@ except ImportError:
import cmd2
from cmd2 import ansi, clipboard, constants, utils
+from cmd2.argparse_completer import CompletionItem
from .conftest import run_cmd, normalize, verify_help_text, HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG
def CreateOutsimApp():
@@ -1504,19 +1505,31 @@ invalid_command_name = [
'noembedded"quotes',
]
-def test_get_alias_names(base_app):
+def test_get_alias_completion_items(base_app):
assert len(base_app.aliases) == 0
run_cmd(base_app, 'alias create fake run_pyscript')
run_cmd(base_app, 'alias create ls !ls -hal')
assert len(base_app.aliases) == 2
- assert sorted(base_app._get_alias_names()) == ['fake', 'ls']
-def test_get_macro_names(base_app):
+ expected = sorted([CompletionItem('fake', 'run_pyscript'), CompletionItem('ls', '!ls -hal')])
+ results = sorted(base_app._get_alias_completion_items())
+
+ for index, cur_res in enumerate(results):
+ assert cur_res == expected[index]
+ assert cur_res.description == expected[index].description
+
+def test_get_macro_completion_items(base_app):
assert len(base_app.macros) == 0
run_cmd(base_app, 'macro create foo !echo foo')
run_cmd(base_app, 'macro create bar !echo bar')
assert len(base_app.macros) == 2
- assert sorted(base_app._get_macro_names()) == ['bar', 'foo']
+
+ expected = sorted([CompletionItem('foo', '!echo foo'), CompletionItem('bar', '!echo bar')])
+ results = sorted(base_app._get_macro_completion_items())
+
+ for index, cur_res in enumerate(results):
+ assert cur_res == expected[index]
+ assert cur_res.description == expected[index].description
def test_get_settable_names(base_app):
assert sorted(base_app._get_settable_names()) == sorted(base_app.settable.keys())