summaryrefslogtreecommitdiff
path: root/tests/test_completion.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-27 21:52:38 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-27 21:52:38 -0400
commita67c694c153fd1d15c266d89bab29076d00919d5 (patch)
tree560dc2c7563e0cf4712e600c2f6c254e666c223d /tests/test_completion.py
parent848372592577f02e03c063c6ec29a349a0f40071 (diff)
parentb4e217239cf176b96aeb3b124eef3609e688d791 (diff)
downloadcmd2-git-a67c694c153fd1d15c266d89bab29076d00919d5.tar.gz
Merge branch 'macro' into argparse_conversion
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r--tests/test_completion.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 7179d2f5..8bf0cc02 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -15,7 +15,7 @@ import sys
import pytest
import cmd2
from cmd2 import utils
-from .conftest import complete_tester
+from .conftest import base_app, complete_tester, normalize, run_cmd
from examples.subcommands import SubcommandsExample
# List of strings used with completion functions
@@ -113,6 +113,23 @@ def test_complete_bogus_command(cmd2_app):
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
assert first_match is None
+def test_complete_macro(base_app, request):
+ # Create the macro
+ out = run_cmd(base_app, 'macro create fake pyscript {1}')
+ assert out == normalize("Macro 'fake' created")
+
+ # Macros do path completion
+ test_dir = os.path.dirname(request.module.__file__)
+
+ text = os.path.join(test_dir, 'script.py')
+ line = 'fake {}'.format(text)
+
+ endidx = len(line)
+ begidx = endidx - len(text)
+
+ first_match = complete_tester(text, line, begidx, endidx, base_app)
+ assert first_match == text + ' '
+
def test_cmd2_command_completion_multiple(cmd2_app):
text = 'h'