@@ -218,30 +218,30 @@ def test_010_check_stdin_closed(paramiko_ssh_client, chan_makefile, auto_add_pol
218218
219219def test_011_execute_async_chroot_cmd (ssh , ssh_transport_channel ):
220220 """Command-only chroot path."""
221- ssh ._execute_async (command , chroot_path = "/" )
221+ ssh ._execute_async (command , chroot_path = "/mnt " )
222222 ssh_transport_channel .assert_has_calls (
223223 (
224224 mock .call .makefile_stderr ("rb" ),
225- mock .call .exec_command (f'chroot / sh -c { shlex .quote (f"eval { quoted_command } " )} \n ' ),
225+ mock .call .exec_command (f'chroot /mnt sh -c { shlex .quote (f"eval { quoted_command } " )} \n ' ),
226226 )
227227 )
228228
229229
230230def test_012_execute_async_chroot_context (ssh , ssh_transport_channel ):
231231 """Context-managed chroot path."""
232- with ssh .chroot ("/" ):
232+ with ssh .chroot ("/mnt " ):
233233 ssh ._execute_async (command )
234234 ssh_transport_channel .assert_has_calls (
235235 (
236236 mock .call .makefile_stderr ("rb" ),
237- mock .call .exec_command (f'chroot / sh -c { shlex .quote (f"eval { quoted_command } " )} \n ' ),
237+ mock .call .exec_command (f'chroot /mnt sh -c { shlex .quote (f"eval { quoted_command } " )} \n ' ),
238238 )
239239 )
240240
241241
242242def test_013_execute_async_no_chroot_context (ssh , ssh_transport_channel ):
243243 """Context-managed chroot path override."""
244- ssh ._chroot_path = "/"
244+ ssh ._chroot_path = "/mnt "
245245
246246 with ssh .chroot (None ):
247247 ssh ._execute_async (command )
@@ -250,12 +250,12 @@ def test_013_execute_async_no_chroot_context(ssh, ssh_transport_channel):
250250
251251def test_012_execute_async_chroot_path (ssh , ssh_transport_channel ):
252252 """Command-only chroot path."""
253- with ssh .chroot (pathlib .Path ("/" )):
253+ with ssh .chroot (pathlib .Path ("/mnt " )):
254254 ssh ._execute_async (command )
255255 ssh_transport_channel .assert_has_calls (
256256 (
257257 mock .call .makefile_stderr ("rb" ),
258- mock .call .exec_command (f'chroot / sh -c { shlex .quote (f"eval { quoted_command } " )} \n ' ),
258+ mock .call .exec_command (f'chroot /mnt sh -c { shlex .quote (f"eval { quoted_command } " )} \n ' ),
259259 )
260260 )
261261
@@ -266,3 +266,12 @@ def test_013_execute_async_chroot_path_invalid_type(ssh, ssh_transport_channel):
266266 with ssh .chroot (...):
267267 ssh ._execute_async (command )
268268 assert str (exc .value ) == f"path={ ...!r} is not instance of Optional[Union[str, pathlib.Path]]"
269+
270+
271+ def test_014_execute_async_no_chroot_root (ssh , ssh_transport_channel ):
272+ """Context-managed chroot path override."""
273+ ssh ._chroot_path = "/mnt"
274+
275+ with ssh .chroot ("/" ):
276+ ssh ._execute_async (command )
277+ ssh_transport_channel .assert_has_calls ((mock .call .makefile_stderr ("rb" ), mock .call .exec_command (f"{ command } \n " )))
0 commit comments