Skip to content
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
19 changes: 0 additions & 19 deletions test/fixtures/scp/bin/ssh

This file was deleted.

8 changes: 5 additions & 3 deletions test/t/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ def partialize(
return first_char, partial_items


def get_testdir():
return os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))


@pytest.fixture(scope="class")
def bash(request) -> pexpect.spawn:
logfile: Optional[TextIO] = None
Expand All @@ -196,9 +200,7 @@ def bash(request) -> pexpect.spawn:
elif os.environ.get("CI"):
logfile = sys.stdout

testdir = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir)
)
testdir = get_testdir()

# Create an empty temporary file for HISTFILE.
#
Expand Down
49 changes: 28 additions & 21 deletions test/t/test_scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
assert_bash_exec,
assert_complete,
bash_env_saved,
get_testdir,
prepare_fixture_dir,
)

Expand All @@ -32,7 +33,7 @@ def test_basic(self, hosts, completion):
)
),
# Local filenames
["bin/", "config", "known_hosts", r"spaced\ \ conf"],
["config", "known_hosts", r"spaced\ \ conf"],
)
)
assert completion == expected
Expand All @@ -52,7 +53,7 @@ def test_basic_spaced_conf(self, hosts, completion):
)
),
# Local filenames
["bin/", "config", "known_hosts", r"spaced\ \ conf"],
["config", "known_hosts", r"spaced\ \ conf"],
)
)
assert completion == expected
Expand All @@ -68,9 +69,9 @@ def test_capital_f_without_space(self, completion):
def test_capital_f_without_space_2(self, completion):
assert completion == "ig"

@pytest.mark.complete("scp -Fbi", cwd="scp")
@pytest.mark.complete("scp -Fempty", cwd="shared")
def test_capital_f_without_space_3(self, completion):
assert completion == "n/"
assert completion == "_dir/"

@pytest.fixture(scope="class")
def live_pwd(self, bash):
Expand Down Expand Up @@ -119,15 +120,15 @@ def test_remote_path_with_spaces(self, bash):
assert_bash_exec(bash, "unset -f ssh")
assert completion == r"\\\ in\\\ filename.txt"

def test_xfunc_remote_files(self, bash):
def test_xfunc_remote_files(self, live_pwd, bash):
def prefix_paths(prefix, paths):
return [f"{prefix}{path}" for path in paths]

with bash_env_saved(bash) as bash_env:
bash_env.save_variable("COMPREPLY")
bash_env.write_variable(
"PATH",
"$PWD/scp/bin:$PATH",
quote=False,
"cur", f"{LIVE_HOST}:{get_testdir()}/fixtures/shared/default/"
)
bash_env.write_variable("cur", "local:shared/default/")
completions_regular_escape = (
assert_bash_exec(
bash,
Expand All @@ -146,18 +147,24 @@ def test_xfunc_remote_files(self, bash):
.strip()
.splitlines()
)
assert completions_regular_escape == [
"shared/default/bar ",
r"shared/default/bar\\\ bar.d/",
"shared/default/foo ",
"shared/default/foo.d/",
]
assert completions_less_escape == [
"shared/default/bar ",
r"shared/default/bar\ bar.d/",
"shared/default/foo ",
"shared/default/foo.d/",
]
assert completions_regular_escape == prefix_paths(
f"{get_testdir()}/fixtures/shared/default/",
[
"bar ",
r"bar\\\ bar.d/",
"foo ",
"foo.d/",
],
)
assert completions_less_escape == prefix_paths(
f"{get_testdir()}/fixtures/shared/default/",
[
"bar ",
r"bar\ bar.d/",
"foo ",
"foo.d/",
],
)

@pytest.fixture
def tmpdir_backslash(self, request, bash):
Expand Down
Loading