summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py52
1 files changed, 36 insertions, 16 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 759ec7d4..f94c0fb0 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1588,6 +1588,42 @@ def test_read_input_rawinput_true(capsys, monkeypatch):
line = app.read_input(prompt_str)
assert line == input_str
+ # Run custom history code
+ import readline
+ readline.add_history('old_history')
+ custom_history = ['cmd1', 'cmd2']
+ line = app.read_input(prompt_str, history=custom_history, completion_mode=cmd2.CompletionMode.NONE)
+ assert line == input_str
+ readline.clear_history()
+
+ # Run all completion modes
+ line = app.read_input(prompt_str, completion_mode=cmd2.CompletionMode.NONE)
+ assert line == input_str
+
+ line = app.read_input(prompt_str, completion_mode=cmd2.CompletionMode.COMMANDS)
+ assert line == input_str
+
+ # custom choices
+ custom_choices = ['choice1', 'choice2']
+ line = app.read_input(prompt_str, completion_mode=cmd2.CompletionMode.CUSTOM,
+ choices=custom_choices)
+ assert line == input_str
+
+ # custom choices_provider
+ line = app.read_input(prompt_str, completion_mode=cmd2.CompletionMode.CUSTOM,
+ choices_provider=cmd2.Cmd.get_all_commands)
+ assert line == input_str
+
+ # custom completer
+ line = app.read_input(prompt_str, completion_mode=cmd2.CompletionMode.CUSTOM,
+ completer=cmd2.Cmd.path_complete)
+ assert line == input_str
+
+ # custom parser
+ line = app.read_input(prompt_str, completion_mode=cmd2.CompletionMode.CUSTOM,
+ parser=cmd2.Cmd2ArgumentParser())
+ assert line == input_str
+
# isatty is False
with mock.patch('sys.stdin.isatty', mock.MagicMock(name='isatty', return_value=False)):
# echo True
@@ -1796,14 +1832,6 @@ def test_alias_create(base_app):
out, err = run_cmd(base_app, 'alias list fake')
assert out == normalize('alias create fake help')
- # Test silent flag
- out, err = run_cmd(base_app, 'alias create --silent fake set')
- assert not out
-
- out, err = run_cmd(base_app, 'alias list --with_silent fake')
- assert out == normalize('alias create --silent fake set')
-
-
def test_alias_create_with_quoted_tokens(base_app):
"""Demonstrate that quotes in alias value will be preserved"""
create_command = 'alias create fake help ">" "out file.txt" ";"'
@@ -1919,14 +1947,6 @@ def test_macro_create(base_app):
out, err = run_cmd(base_app, 'macro list fake')
assert out == normalize('macro create fake help')
- # Test silent flag
- out, err = run_cmd(base_app, 'macro create --silent fake set')
- assert not out
-
- out, err = run_cmd(base_app, 'macro list --with_silent fake')
- assert out == normalize('macro create --silent fake set')
-
-
def test_macro_create_with_quoted_tokens(base_app):
"""Demonstrate that quotes in macro value will be preserved"""
create_command = 'macro create fake help ">" "out file.txt" ";"'