summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-09-17 10:04:25 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-09-17 10:04:25 -0400
commit17eefdeb934525772885ff31f80a0d5a016a5b52 (patch)
treeaf2c2be429ebf31183826fceaafe23581a38a3b4 /tests
parent60ab11c3166a2a76bf67774c67b583d7d30fe5be (diff)
downloadcmd2-git-17eefdeb934525772885ff31f80a0d5a016a5b52.tar.gz
No longer printing all help text for alias and macro when the subcommand is omitted. Instead allow argparse to handle the error.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_cmd2.py6
-rwxr-xr-xtests/test_completion.py2
-rw-r--r--tests/test_transcript.py4
3 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index fc8a1dae..94a49a95 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1620,7 +1620,8 @@ def test_get_settable_completion_items(base_app):
def test_alias_no_subcommand(base_app):
out, err = run_cmd(base_app, 'alias')
- assert "Usage: alias [-h]" in out[0]
+ assert "Usage: alias [-h]" in err[0]
+ assert "Error: the following arguments are required: subcommand" in err[1]
def test_alias_create(base_app):
# Create the alias
@@ -1713,7 +1714,8 @@ def test_multiple_aliases(base_app):
def test_macro_no_subcommand(base_app):
out, err = run_cmd(base_app, 'macro')
- assert "Usage: macro [-h]" in out[0]
+ assert "Usage: macro [-h]" in err[0]
+ assert "Error: the following arguments are required: subcommand" in err[1]
def test_macro_create(base_app):
# Create the macro
diff --git a/tests/test_completion.py b/tests/test_completion.py
index fb0d74e0..c7d9bd21 100755
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -1179,7 +1179,7 @@ def test_cmd2_help_subcommand_completion_with_flags_before_command(scu_app):
first_match = complete_tester(text, line, begidx, endidx, scu_app)
assert first_match is not None and scu_app.completion_matches == ['bar', 'foo', 'sport']
-def test_complete_help_subcommand_with_blank_command(scu_app):
+def test_complete_help_subcommands_with_blank_command(scu_app):
text = ''
line = 'help "" {}'.format(text)
endidx = len(line)
diff --git a/tests/test_transcript.py b/tests/test_transcript.py
index 1d930c26..5739ad8e 100644
--- a/tests/test_transcript.py
+++ b/tests/test_transcript.py
@@ -224,13 +224,13 @@ def test_generate_transcript_stop(capsys):
os.close(fd)
# This should run all commands
- commands = ['help', 'alias']
+ commands = ['help', 'set']
app._generate_transcript(commands, transcript_fname)
_, err = capsys.readouterr()
assert err.startswith("2 commands")
# Since quit returns True for stop, only the first 2 commands will run
- commands = ['help', 'quit', 'alias']
+ commands = ['help', 'quit', 'set']
app._generate_transcript(commands, transcript_fname)
_, err = capsys.readouterr()
assert err.startswith("Command 2 triggered a stop")