summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-04-05 18:10:45 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-04-05 18:10:45 -0400
commite56619636d39a072b4f583fd25f8e658a43792a9 (patch)
tree7d0492f04850224cf8e2fef5a9c576b32ea97c2e /tests
parentebe8873448cdaadbca620bf6eb5e22f9e79f25fc (diff)
downloadcmd2-git-e56619636d39a072b4f583fd25f8e658a43792a9.tar.gz
Added unit test for path completion in root directory
Diffstat (limited to 'tests')
-rw-r--r--tests/test_completion.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 0916e500..23843012 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -400,6 +400,25 @@ def test_path_completion_no_path(cmd2_app):
assert completions_no_text == completions_cwd
assert completions_cwd
+
+@pytest.mark.skipif(sys.platform == 'win32', reason="this only applies on systems where the root directory is a slash")
+def test_path_completion_cwd_is_root_dir(cmd2_app):
+ # Change our CWD to root dir
+ cwd = os.getcwd()
+ os.chdir(os.path.sep)
+
+ text = ''
+ line = 'shell ls {}'.format(text)
+ endidx = len(line)
+ begidx = endidx - len(text)
+ completions = cmd2_app.path_complete(text, line, begidx, endidx)
+
+ # No match should start with a slash
+ assert not any(match.startswith(os.path.sep) for match in completions)
+
+ # Restore CWD
+ os.chdir(cwd)
+
def test_path_completion_doesnt_match_wildcards(cmd2_app, request):
test_dir = os.path.dirname(request.module.__file__)