From 88e724384c4141d85df34bf3255f84e26ce4bc84 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 2 Apr 2025 10:13:51 +0200 Subject: [PATCH] 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. --- tests/pexpects/history.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/pexpects/history.py b/tests/pexpects/history.py index e62b262c8..dd0be4289 100644 --- a/tests/pexpects/history.py +++ b/tests/pexpects/history.py @@ -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" )