pexpects/history.py: reduce surprise in env setup

This "SpawnedProc(env=os.environ.copy())" seems redundant but it's not, since
the default argument is initialized (with a copy of env) at module-load time.
Reshuffle the code to make it look less odd.

While at it, fix some invalid escape sequence warnings.
This commit is contained in:
Johannes Altmanninger
2025-04-02 10:13:51 +02:00
parent 50a6e486a5
commit 88e724384c

View File

@@ -14,9 +14,10 @@
from pexpect_helper import SpawnedProc
import os
os.environ["PAGER"] = "cat"
env = os.environ.copy()
env["PAGER"] = "cat"
sp = SpawnedProc(env=os.environ.copy())
sp = SpawnedProc(env=env)
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
sp.send,
@@ -108,8 +109,8 @@ expect_prompt("count hello 0\r\n")
# sent above that matches).
sendline("history delete -p 'echo hello'")
expect_re("history delete -p 'echo hello'\r\n")
expect_re("\[1\] echo hello AGAIN\r\n")
expect_re("\[2\] echo hello again\r\n\r\n")
expect_re(r"\[1\] echo hello AGAIN\r\n")
expect_re(r"\[2\] echo hello again\r\n\r\n")
expect_re(
"Enter nothing to cancel the delete, or\r\nEnter one or more of the entry IDs or ranges like '5..12', separated by a space.\r\nFor example '7 10..15 35 788..812'.\r\nEnter 'all' to delete all the matching entries.\r\n"
)