summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-08-06 23:25:57 -0400
committerGitHub <noreply@github.com>2019-08-06 23:25:57 -0400
commit89a5a646ffa2f72154b932f0b2dbf23fd87866e3 (patch)
treeaf96ef532ea2eac818b2cf4591eec41959db1528 /tests/test_cmd2.py
parent0f9fcfcd95ee7fd30ebddabbf2068d8ddb725364 (diff)
parentd210846e4df74f6b88995ccfabc3ae25f2b333c9 (diff)
downloadcmd2-git-89a5a646ffa2f72154b932f0b2dbf23fd87866e3.tar.gz
Merge pull request #752 from python-cmd2/restrict_alias_macro_names
Removed ability for aliases and macros to share names with commands
Diffstat (limited to 'tests/test_cmd2.py')
-rwxr-xr-xtests/test_cmd2.py46
1 files changed, 8 insertions, 38 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 8389b9ed..1ba10f6b 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1625,6 +1625,10 @@ def test_alias_create_invalid_name(base_app, alias_name, capsys):
out, err = run_cmd(base_app, 'alias create {} help'.format(alias_name))
assert "Invalid alias name" in err[0]
+def test_alias_create_with_command_name(base_app):
+ out, err = run_cmd(base_app, 'alias create help stuff')
+ assert "Alias cannot have the same name as a command" in err[0]
+
def test_alias_create_with_macro_name(base_app):
macro = "my_macro"
run_cmd(base_app, 'macro create {} help'.format(macro))
@@ -1713,19 +1717,16 @@ def test_macro_create_invalid_name(base_app, macro_name):
out, err = run_cmd(base_app, 'macro create {} help'.format(macro_name))
assert "Invalid macro name" in err[0]
+def test_macro_create_with_command_name(base_app):
+ out, err = run_cmd(base_app, 'macro create help stuff')
+ assert "Macro cannot have the same name as a command" in err[0]
+
def test_macro_create_with_alias_name(base_app):
macro = "my_macro"
run_cmd(base_app, 'alias create {} help'.format(macro))
out, err = run_cmd(base_app, 'macro create {} help'.format(macro))
assert "Macro cannot have the same name as an alias" in err[0]
-def test_macro_create_with_command_name(multiline_app):
- out, err = run_cmd(multiline_app, 'macro create help stuff')
- assert out == normalize("Macro 'help' created")
-
- out, err = run_cmd(multiline_app, 'macro create orate stuff')
- assert "Macro cannot have the same name as a multiline command" in err[0]
-
def test_macro_create_with_args(base_app):
# Create the macro
out, err = run_cmd(base_app, 'macro create fake {1} {2}')
@@ -1843,37 +1844,6 @@ def test_nonexistent_macro(base_app):
assert exception is not None
-def test_input_line_to_statement_expand(base_app):
- # Enable/Disable expansion of shortcuts
- line = '!ls'
- statement = base_app._input_line_to_statement(line, expand=True)
- assert statement.command == 'shell'
-
- statement = base_app._input_line_to_statement(line, expand=False)
- assert statement.command == '!ls'
-
- # Enable/Disable expansion of aliases
- run_cmd(base_app, 'alias create help macro')
-
- line = 'help'
- statement = base_app._input_line_to_statement(line, expand=True)
- assert statement.command == 'macro'
-
- statement = base_app._input_line_to_statement(line, expand=False)
- assert statement.command == 'help'
-
- run_cmd(base_app, 'alias delete help')
-
- # Enable/Disable expansion of macros
- run_cmd(base_app, 'macro create help alias')
-
- line = 'help'
- statement = base_app._input_line_to_statement(line, expand=True)
- assert statement.command == 'alias'
-
- statement = base_app._input_line_to_statement(line, expand=False)
- assert statement.command == 'help'
-
def test_ppaged(outsim_app):
msg = 'testing...'
end = '\n'