diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-16 22:45:53 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-16 22:45:53 -0400 |
commit | 3bf1c51b3218ffdd00c1369dac0160cab38b738a (patch) | |
tree | 205d44259d76cbf608010a98f76bd7e1768f25a9 /tests/test_completion.py | |
parent | 411f19334de2663d159428538e61a80aa7c98bad (diff) | |
parent | 286ae5c958e0132ccc82f170aa08521bb6439f64 (diff) | |
download | cmd2-git-3bf1c51b3218ffdd00c1369dac0160cab38b738a.tar.gz |
Merge branch 'master' into startup_script
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r-- | tests/test_completion.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py index a9f75dce..7f9a6db0 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -311,6 +311,45 @@ def test_path_completion_nomatch(request): assert path_complete(text, line, begidx, endidx) == [] + +def test_default_to_shell_completion(cmd2_app, request): + cmd2_app.default_to_shell = True + test_dir = os.path.dirname(request.module.__file__) + + text = 'c' + path = os.path.join(test_dir, text) + + if sys.platform == "win32": + command = 'calc.exe' + else: + command = 'egrep' + + # Make sure the command is on the testing system + assert command in cmd2.Cmd._get_exes_in_path(command) + line = '{} {}'.format(command, path) + + endidx = len(line) + begidx = endidx - len(text) + state = 0 + + def get_line(): + return line + + def get_begidx(): + return begidx + + def get_endidx(): + return endidx + + with mock.patch.object(readline, 'get_line_buffer', get_line): + with mock.patch.object(readline, 'get_begidx', get_begidx): + with mock.patch.object(readline, 'get_endidx', get_endidx): + # Run the readline tab-completion function with readline mocks in place + first_match = cmd2_app.complete(text, state) + + assert first_match is not None and cmd2_app.completion_matches == ['conftest.py '] + + def test_path_completion_cwd(): # Run path complete with no path and no search text text = '' |