8
8
assert_bash_exec ,
9
9
assert_complete ,
10
10
bash_env_saved ,
11
+ get_testdir ,
11
12
prepare_fixture_dir ,
12
13
)
13
14
@@ -32,7 +33,7 @@ def test_basic(self, hosts, completion):
32
33
)
33
34
),
34
35
# Local filenames
35
- ["bin/" , " config" , "known_hosts" , r"spaced\ \ conf" ],
36
+ ["config" , "known_hosts" , r"spaced\ \ conf" ],
36
37
)
37
38
)
38
39
assert completion == expected
@@ -52,7 +53,7 @@ def test_basic_spaced_conf(self, hosts, completion):
52
53
)
53
54
),
54
55
# Local filenames
55
- ["bin/" , " config" , "known_hosts" , r"spaced\ \ conf" ],
56
+ ["config" , "known_hosts" , r"spaced\ \ conf" ],
56
57
)
57
58
)
58
59
assert completion == expected
@@ -68,9 +69,9 @@ def test_capital_f_without_space(self, completion):
68
69
def test_capital_f_without_space_2 (self , completion ):
69
70
assert completion == "ig"
70
71
71
- @pytest .mark .complete ("scp -Fbi " , cwd = "scp " )
72
+ @pytest .mark .complete ("scp -Fempty " , cwd = "shared " )
72
73
def test_capital_f_without_space_3 (self , completion ):
73
- assert completion == "n /"
74
+ assert completion == "_dir /"
74
75
75
76
@pytest .fixture (scope = "class" )
76
77
def live_pwd (self , bash ):
@@ -119,15 +120,15 @@ def test_remote_path_with_spaces(self, bash):
119
120
assert_bash_exec (bash , "unset -f ssh" )
120
121
assert completion == r"\\\ in\\\ filename.txt"
121
122
122
- def test_xfunc_remote_files (self , bash ):
123
+ def test_xfunc_remote_files (self , live_pwd , bash ):
124
+ def prefix_paths (prefix , paths ):
125
+ return [f"{ prefix } { path } " for path in paths ]
126
+
123
127
with bash_env_saved (bash ) as bash_env :
124
128
bash_env .save_variable ("COMPREPLY" )
125
129
bash_env .write_variable (
126
- "PATH" ,
127
- "$PWD/scp/bin:$PATH" ,
128
- quote = False ,
130
+ "cur" , f"{ LIVE_HOST } :{ get_testdir ()} /fixtures/shared/default/"
129
131
)
130
- bash_env .write_variable ("cur" , "local:shared/default/" )
131
132
completions_regular_escape = (
132
133
assert_bash_exec (
133
134
bash ,
@@ -146,18 +147,24 @@ def test_xfunc_remote_files(self, bash):
146
147
.strip ()
147
148
.splitlines ()
148
149
)
149
- assert completions_regular_escape == [
150
- "shared/default/bar " ,
151
- r"shared/default/bar\\\ bar.d/" ,
152
- "shared/default/foo " ,
153
- "shared/default/foo.d/" ,
154
- ]
155
- assert completions_less_escape == [
156
- "shared/default/bar " ,
157
- r"shared/default/bar\ bar.d/" ,
158
- "shared/default/foo " ,
159
- "shared/default/foo.d/" ,
160
- ]
150
+ assert completions_regular_escape == prefix_paths (
151
+ f"{ get_testdir ()} /fixtures/shared/default/" ,
152
+ [
153
+ "bar " ,
154
+ r"bar\\\ bar.d/" ,
155
+ "foo " ,
156
+ "foo.d/" ,
157
+ ],
158
+ )
159
+ assert completions_less_escape == prefix_paths (
160
+ f"{ get_testdir ()} /fixtures/shared/default/" ,
161
+ [
162
+ "bar " ,
163
+ r"bar\ bar.d/" ,
164
+ "foo " ,
165
+ "foo.d/" ,
166
+ ],
167
+ )
161
168
162
169
@pytest .fixture
163
170
def tmpdir_backslash (self , request , bash ):
0 commit comments