Skip to content

Commit e8aeed7

Browse files
committed
test(scp): test spaces after completing filenames ending with '\'
The test has not been prepared because the ending spaces cannot be tested with the typical comparison of `completion == "..."` or `completion == [...]`, but it turned out that existing teset cases uses `completion.output` to check suffixing spaces. This patch implements the test using `completion.output`. #1397 (comment)
1 parent 9be1eed commit e8aeed7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/t/test_scp.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
from itertools import chain
34

45
import pytest
@@ -158,6 +159,28 @@ def test_xfunc_remote_files(self, bash):
158159
"shared/default/foo.d/",
159160
]
160161

162+
@pytest.fixture
163+
def tmpdir_backslash(self, request, bash):
164+
if sys.platform.startswith("win"):
165+
pytest.skip("Filenames not allowed on Windows")
166+
167+
tmpdir, _, _ = prepare_fixture_dir(
168+
request, files=["local_path-file\\"], dirs=[]
169+
)
170+
return tmpdir
171+
172+
def test_local_path_ending_with_backslash(self, bash, tmpdir_backslash):
173+
completion = assert_complete(
174+
bash, "scp local_path-", cwd=tmpdir_backslash
175+
)
176+
assert completion.output == r"file\\ "
177+
178+
def test_remote_path_ending_with_backslash(self, bash):
179+
assert_bash_exec(bash, "ssh() { echo 'hypothetical\\'; }")
180+
completion = assert_complete(bash, "scp remote_host:hypo")
181+
assert_bash_exec(bash, "unset -f ssh")
182+
assert completion.output == r"thetical\\\\ "
183+
161184
@pytest.fixture
162185
def tmpdir_mkfifo(self, request, bash):
163186
tmpdir, _, _ = prepare_fixture_dir(request, files=[], dirs=[])

0 commit comments

Comments
 (0)