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.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index faef21f9..af1d41c9 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -24,8 +24,7 @@ except ImportError:
from unittest import mock
import cmd2
-from cmd2 import clipboard
-from cmd2 import utils
+from cmd2 import clipboard, constants, utils
from .conftest import run_cmd, normalize, BASE_HELP, BASE_HELP_VERBOSE, \
HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG
@@ -1828,6 +1827,7 @@ def test_poutput_color_never(base_app):
# These are invalid names for aliases and macros
invalid_command_name = [
'""', # Blank name
+ constants.COMMENT_CHAR,
'!no_shortcut',
'">"',
'"no>pe"',
@@ -1900,6 +1900,17 @@ def test_alias_create_with_macro_name(base_app, capsys):
out, err = capsys.readouterr()
assert "Alias cannot have the same name as a macro" in err
+def test_alias_that_resolves_into_comment(base_app, capsys):
+ # Create the alias
+ out = run_cmd(base_app, 'alias create fake ' + constants.COMMENT_CHAR + ' blah blah')
+ assert out == normalize("Alias 'fake' created")
+
+ # Use the alias
+ run_cmd(base_app, 'fake')
+ out, err = capsys.readouterr()
+ assert not out
+ assert not err
+
def test_alias_list_invalid_alias(base_app, capsys):
# Look up invalid alias
out = run_cmd(base_app, 'alias list invalid')
@@ -2056,6 +2067,17 @@ def test_macro_create_with_missing_unicode_arg_nums(base_app, capsys):
out, err = capsys.readouterr()
assert "Not all numbers between 1 and 3" in err
+def test_macro_that_resolves_into_comment(base_app, capsys):
+ # Create the macro
+ out = run_cmd(base_app, 'macro create fake {1} blah blah')
+ assert out == normalize("Macro 'fake' created")
+
+ # Use the macro
+ run_cmd(base_app, 'fake ' + constants.COMMENT_CHAR)
+ out, err = capsys.readouterr()
+ assert not out
+ assert not err
+
def test_macro_list_invalid_macro(base_app, capsys):
# Look up invalid macro
run_cmd(base_app, 'macro list invalid')