@@ -392,9 +392,8 @@ def test_shell_hostname_escaping(
392392 tmp_path .joinpath ("etc/hostname" ).write_bytes (b"hostname\x00 \x01 \x02 \x03 " )
393393
394394 sys .stdout .flush ()
395- out , err = run_target_shell (monkeypatch , capsys , str (tmp_path ), "\n " )
395+ out , _ = run_target_shell (monkeypatch , capsys , str (tmp_path ), "\n " )
396396
397- assert not err
398397 assert "hostname\\ x00\\ x01\\ x02\\ x03" in out
399398
400399
@@ -422,17 +421,32 @@ def ansi_new_data(cls: pexpect.expect.Expecter, data: bytes) -> int | None:
422421 # increase window size to avoid line wrapping
423422 child .setwinsize (100 , 100 )
424423
425- # note that the expect pattern will be re.compiled so we need to escape regex special characters
426- child .expect (re .escape ("ubuntu:/$ " ), timeout = 20 )
424+ if platform .python_implementation () == "PyPy" :
425+ major , minor , _patch = tuple (map (int , platform .python_version_tuple ()))
426+ if major < 3 or (major == 3 and (minor < 10 or (minor == 10 and _patch < 14 ))):
427+ child .expect_exact (
428+ "Note for users of PyPy < 3.10.14:\n "
429+ "Autocomplete might not work due to an outdated version of pyrepl/readline.py\n "
430+ "To fix this, please update your version of PyPy.\n " ,
431+ timeout = 30 ,
432+ )
433+ child .expect_exact ("ubuntu:/$ " , timeout = 5 )
434+ child .sendline ("exit" )
435+ child .expect (pexpect .EOF , timeout = 5 )
436+ return
437+
438+ pytest .skip ("PyPy in CI does not have a functional readline" )
439+
440+ child .expect_exact ("ubuntu:/$ " , timeout = 30 )
427441 # this should auto complete to `ls /home/user`
428- child .sendline ("ls /home/u\t " )
442+ child .send ("ls /home/u\t " )
429443 # expect the prompt to be printed again
430- child .expect ( re . escape ( "ls /home/user/\n " ) , timeout = 5 )
444+ child .expect_exact ( "ls /home/user/" , timeout = 5 )
431445 # execute the autocompleted command
432446 child .send ("\n " )
433447 # we expect the files in /home/user to be printed
434- child .expect ( re . escape ( ".bash_history\n .zsh_history\n " ) , timeout = 5 )
435- child .expect ( re . escape ( "ubuntu:/$ " ) , timeout = 5 )
448+ child .expect_exact ( ".bash_history\n .zsh_history\n " , timeout = 5 )
449+ child .expect_exact ( "ubuntu:/$ " , timeout = 5 )
436450
437451 # send partial ls /etc/ command
438452 child .send ("ls /etc/" )
@@ -449,9 +463,9 @@ def ansi_new_data(cls: pexpect.expect.Expecter, data: bytes) -> int | None:
449463 # send newline to just list everything in /etc/
450464 child .send ("\n " )
451465 # expect the last few files in /etc/ to be printed
452- child .expect ("shadow\n timezone\n " , timeout = 5 )
466+ child .expect_exact ("shadow\n timezone\n " , timeout = 5 )
453467
454468 # exit the shell
455- child .expect ( re . escape ( "ubuntu:/$ " ) , timeout = 5 )
469+ child .expect_exact ( "ubuntu:/$ " , timeout = 5 )
456470 child .sendline ("exit" )
457471 child .expect (pexpect .EOF , timeout = 5 )
0 commit comments