@@ -158,6 +158,44 @@ def test_put_file_with_spaces(self):
158158 stdin = PIPE ,
159159 )
160160
161+ def test_put_file_tilde_expansion (self ):
162+ inventory = make_inventory (hosts = ("@local" ,))
163+ State (inventory , Config ())
164+
165+ host = inventory .get_host ("@local" )
166+
167+ fake_process = MagicMock (returncode = 0 )
168+ self .fake_popen_mock .return_value = fake_process
169+
170+ host .put_file ("not-a-file" , "~/file-in-home-directory" , print_output = True )
171+
172+ self .fake_popen_mock .assert_called_with (
173+ "sh -c 'cp __tempfile__ ~/file-in-home-directory'" ,
174+ shell = True ,
175+ stdout = PIPE ,
176+ stderr = PIPE ,
177+ stdin = PIPE ,
178+ )
179+
180+ def test_put_file_tilde_expansion_with_spaces (self ):
181+ inventory = make_inventory (hosts = ("@local" ,))
182+ State (inventory , Config ())
183+
184+ host = inventory .get_host ("@local" )
185+
186+ fake_process = MagicMock (returncode = 0 )
187+ self .fake_popen_mock .return_value = fake_process
188+
189+ host .put_file ("not-a-file" , "~/not another file with spaces" , print_output = True )
190+
191+ self .fake_popen_mock .assert_called_with (
192+ "sh -c 'cp __tempfile__ ~/'\" '\" 'not another file with spaces'\" '\" ''" ,
193+ shell = True ,
194+ stdout = PIPE ,
195+ stderr = PIPE ,
196+ stdin = PIPE ,
197+ )
198+
161199 def test_put_file_error (self ):
162200 inventory = make_inventory (hosts = ("@local" ,))
163201 State (inventory , Config ())
0 commit comments