summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-16 21:42:03 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-16 21:42:03 -0400
commit0d592167fc74d7bc65ae4a0b58798b7f0ee396a8 (patch)
treeab235bf7d2406a2f5cd8b708d8483e44a1fc942a
parentadd272fb1d446034ed3bb1001939baa3e8cd2bfb (diff)
downloadcmd2-git-0d592167fc74d7bc65ae4a0b58798b7f0ee396a8.tar.gz
Skip test_default_to_shell_completion unit test on Windows
Python's built-in cmd module (and cmd2 which inherits from it) parses the command line and has relatively strict rules when parsing the beginning of the line looking for a "command". This command can must consist of ASCII letters and digits. The parsing logic applies prior to the default_to_shell flag attempting to run this "command" as a shell command. A problem occurs on Windows in that nearly all executables have a "." in their name. cmd/cmd2 will view everything before the "." as being the command. On Windows, I would strongly encourage the use of "!" or "shell" to run shell commands and would recommend against using the "default_to_shell" flag unless you are working within the Windows Subsystem for Linux (WSL).
-rw-r--r--tests/test_completion.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 7f9a6db0..78d045d7 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -311,18 +311,15 @@ def test_path_completion_nomatch(request):
assert path_complete(text, line, begidx, endidx) == []
-
+@pytest.mark.skipif(sys.platform == 'win32',
+ reason="cmd command parsing only supports ascii characters and digits as part of a command name")
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'
+ command = 'egrep'
# Make sure the command is on the testing system
assert command in cmd2.Cmd._get_exes_in_path(command)