pexpects: Fix some escapes

Python has become stricter about unknown `\x` in strings, firing a
SyntaxWarning right now.

They need to be `\\x`.
This commit is contained in:
Fabian Boehm 2024-12-26 14:25:36 +01:00
parent c473aa60a7
commit 36c632889b
4 changed files with 8 additions and 8 deletions

View file

@ -42,7 +42,7 @@ sendline(
"function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end" "function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
) )
expect_prompt() expect_prompt()
sendline("echo \en one \"two three\" four'five six'{7} 'eight~") sendline("echo \\en one \"two three\" four'five six'{7} 'eight~")
expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n") expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n")
# printing the buffer with -o should remove quoting # printing the buffer with -o should remove quoting

View file

@ -43,6 +43,6 @@ expect_prompt()
send("fooc \t") send("fooc \t")
expect_re( expect_re(
"india\W+hotel\W+charlie\W+alpha\W+delta\W+kilo\r\n" "india\\W+hotel\\W+charlie\\W+alpha\\W+delta\\W+kilo\r\n"
+ "foxtrot\W+golf\W+echo\W+bravo\W+juliett\W+lima" + "foxtrot\\W+golf\\W+echo\\W+bravo\\W+juliett\\W+lima"
) )

View file

@ -31,7 +31,7 @@ expect_re(
+ "\r\nin command substitution" + "\r\nin command substitution"
+ "\r\nfish: Unable to evaluate string substitution" + "\r\nfish: Unable to evaluate string substitution"
+ re.escape("\r\neval (string replace dog tiger -- $history[1])") + re.escape("\r\neval (string replace dog tiger -- $history[1])")
+ "\r\n *\^~+\^\w*" + "\r\n *\\^~+\\^\\w*"
) )
expect_prompt() expect_prompt()

View file

@ -108,13 +108,13 @@ expect_prompt("count hello 0\r\n")
# sent above that matches). # sent above that matches).
sendline("history delete -p 'echo hello'") sendline("history delete -p 'echo hello'")
expect_re("history delete -p 'echo hello'" + TO_END_SUFFIX) expect_re("history delete -p 'echo hello'" + TO_END_SUFFIX)
expect_re("\[1\] echo hello AGAIN" + TO_END_SUFFIX) expect_re("\\[1\\] echo hello AGAIN" + TO_END_SUFFIX)
expect_re("\[2\] echo hello again" + TO_END_SUFFIX) expect_re("\\[2\\] echo hello again" + TO_END_SUFFIX)
expect_re("Enter nothing to cancel the delete, or\r\n") expect_re("Enter nothing to cancel the delete, or\r\n")
expect_re("Enter one or more of the entry IDs or ranges like '5..12', separated by a space.\r\n") expect_re("Enter one or more of the entry IDs or ranges like '5..12', separated by a space.\r\n")
expect_re("For example '7 10..15 35 788..812'.\r\n") expect_re("For example '7 10..15 35 788..812'.\r\n")
expect_re("Enter 'all' to delete all the matching entries.\r\n") expect_re("Enter 'all' to delete all the matching entries.\r\n")
expect_re("Delete which entries\? ") expect_re("Delete which entries\\? ")
sendline("1") sendline("1")
expect_prompt('Deleting history entry 1: "echo hello AGAIN"\r\n') expect_prompt('Deleting history entry 1: "echo hello AGAIN"\r\n')
@ -131,7 +131,7 @@ sendline(
expect_prompt("count again 1\r\n") expect_prompt("count again 1\r\n")
# Verify that the $history var has the expected content. # Verify that the $history var has the expected content.
sendline("echo history2=$history\[2\]") sendline("echo history2=$history[2]")
expect_prompt("history2=echo count AGAIN .*\r\n") expect_prompt("history2=echo count AGAIN .*\r\n")
# Verify that history search is case-insensitive by default # Verify that history search is case-insensitive by default