summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorkmvanbrunt <kmvanbrunt@gmail.com>2018-10-12 17:43:59 -0400
committerGitHub <noreply@github.com>2018-10-12 17:43:59 -0400
commit3dcff6406ff772678d2e003a0fd56c5a64d39e60 (patch)
tree5ff4f56b0eee7191b6079039eadb722966e8565d /tests/test_cmd2.py
parentb216987165d7783903e02db006cf5055f2615796 (diff)
parent53b976a7aeae88f811391820ca93aaa21b6501e9 (diff)
downloadcmd2-git-3dcff6406ff772678d2e003a0fd56c5a64d39e60.tar.gz
Merge pull request #576 from python-cmd2/extra_args
You can now call a macro with extra arguments
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index a2bd6197..de1ed76a 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -2014,6 +2014,25 @@ def test_macro_create_with_escaped_args(base_app, capsys):
out = run_cmd(base_app, 'fake')
assert 'No help on {1}' in out[0]
+def test_macro_usage_with_missing_args(base_app, capsys):
+ # Create the macro
+ out = run_cmd(base_app, 'macro create fake help {1} {2}')
+ assert out == normalize("Macro 'fake' created")
+
+ # Run the macro
+ run_cmd(base_app, 'fake arg1')
+ out, err = capsys.readouterr()
+ assert "expects at least 2 argument(s)" in err
+
+def test_macro_usage_with_exta_args(base_app, capsys):
+ # Create the macro
+ out = run_cmd(base_app, 'macro create fake help {1}')
+ assert out == normalize("Macro 'fake' created")
+
+ # Run the macro
+ out = run_cmd(base_app, 'fake alias create')
+ assert "Usage: alias create" in out[0]
+
def test_macro_create_with_missing_arg_nums(base_app, capsys):
# Create the macro
run_cmd(base_app, 'macro create fake help {1} {3}')
@@ -2026,16 +2045,6 @@ def test_macro_create_with_invalid_arg_num(base_app, capsys):
out, err = capsys.readouterr()
assert "Argument numbers must be greater than 0" in err
-def test_macro_create_with_wrong_arg_count(base_app, capsys):
- # Create the macro
- out = run_cmd(base_app, 'macro create fake help {1} {2}')
- assert out == normalize("Macro 'fake' created")
-
- # Run the macro
- run_cmd(base_app, 'fake arg1')
- out, err = capsys.readouterr()
- assert "expects 2 argument(s)" in err
-
def test_macro_create_with_unicode_numbered_arg(base_app, capsys):
# Create the macro expecting 1 argument
out = run_cmd(base_app, 'macro create fake help {\N{ARABIC-INDIC DIGIT ONE}}')
@@ -2044,7 +2053,7 @@ def test_macro_create_with_unicode_numbered_arg(base_app, capsys):
# Run the macro
out = run_cmd(base_app, 'fake')
out, err = capsys.readouterr()
- assert "expects 1 argument(s)" in err
+ assert "expects at least 1 argument(s)" in err
def test_macro_create_with_missing_unicode_arg_nums(base_app, capsys):
run_cmd(base_app, 'macro create fake help {1} {\N{ARABIC-INDIC DIGIT THREE}}')