Skip to content

Commit 0396d24

Browse files
authored
Merge pull request #1408 from akinomyoga/scp-refactor-1-4
test(sshfs,scp): create files on the fly to work around Windows filesystem
2 parents 1631952 + c3d122a commit 0396d24

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

test/fixtures/sshfs/local_path-dir/dummy.txt

Whitespace-only changes.

test/fixtures/sshfs/local_path-file\

Whitespace-only changes.

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=[])

test/t/test_sshfs.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import sys
2+
13
import pytest
24

3-
from conftest import assert_bash_exec, assert_complete
5+
from conftest import assert_bash_exec, assert_complete, prepare_fixture_dir
46

57

68
@pytest.mark.bashcomp(ignore_env=r"^[+-]_comp_cmd_scp__path_esc=")
@@ -9,8 +11,21 @@ class TestSshfs:
911
def test_1(self, completion):
1012
assert completion
1113

12-
@pytest.mark.complete("sshfs local_path", cwd="sshfs")
13-
def test_local_path_suffix_1(self, completion):
14+
@pytest.fixture
15+
def tmpdir_backslash(self, request, bash):
16+
if sys.platform.startswith("win"):
17+
pytest.skip("Filenames not allowed on Windows")
18+
19+
tmpdir, _, _ = prepare_fixture_dir(
20+
request, files=["local_path-file\\"], dirs=["local_path-dir"]
21+
)
22+
return tmpdir
23+
24+
def test_local_path_suffix_1(self, bash, tmpdir_backslash):
25+
completion = assert_complete(
26+
bash, "sshfs local_path", cwd=tmpdir_backslash
27+
)
28+
1429
assert completion == "-dir/"
1530

1631
def test_remote_path_ending_with_backslash(self, bash):

0 commit comments

Comments
 (0)