Skip to content

test(sshfs,scp): create files on the fly to work around Windows filesystem #1408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions test/t/test_scp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
from itertools import chain

import pytest
Expand Down Expand Up @@ -158,6 +159,28 @@ def test_xfunc_remote_files(self, bash):
"shared/default/foo.d/",
]

@pytest.fixture
def tmpdir_backslash(self, request, bash):
if sys.platform.startswith("win"):
pytest.skip("Filenames not allowed on Windows")

tmpdir, _, _ = prepare_fixture_dir(
request, files=["local_path-file\\"], dirs=[]
)
return tmpdir

def test_local_path_ending_with_backslash(self, bash, tmpdir_backslash):
completion = assert_complete(
bash, "scp local_path-", cwd=tmpdir_backslash
)
assert completion.output == r"file\\ "

def test_remote_path_ending_with_backslash(self, bash):
assert_bash_exec(bash, "ssh() { echo 'hypothetical\\'; }")
completion = assert_complete(bash, "scp remote_host:hypo")
assert_bash_exec(bash, "unset -f ssh")
assert completion.output == r"thetical\\\\ "

@pytest.fixture
def tmpdir_mkfifo(self, request, bash):
tmpdir, _, _ = prepare_fixture_dir(request, files=[], dirs=[])
Expand Down
21 changes: 18 additions & 3 deletions test/t/test_sshfs.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not remove the test/fixtures/sshfs dir and its contents as part of this change? It would seem to be unused after this, and would still cause problems if around I guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. I completely forgot that. I'll address it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys

import pytest

from conftest import assert_bash_exec, assert_complete
from conftest import assert_bash_exec, assert_complete, prepare_fixture_dir


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

@pytest.mark.complete("sshfs local_path", cwd="sshfs")
def test_local_path_suffix_1(self, completion):
@pytest.fixture
def tmpdir_backslash(self, request, bash):
if sys.platform.startswith("win"):
pytest.skip("Filenames not allowed on Windows")

tmpdir, _, _ = prepare_fixture_dir(
request, files=["local_path-file\\"], dirs=["local_path-dir"]
)
return tmpdir

def test_local_path_suffix_1(self, bash, tmpdir_backslash):
completion = assert_complete(
bash, "sshfs local_path", cwd=tmpdir_backslash
)

assert completion == "-dir/"

def test_remote_path_ending_with_backslash(self, bash):
Expand Down