From 10fbdd34e7f26650010afa60a4294b6df552de2f Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 8 Jun 2020 17:32:56 +0200 Subject: [PATCH] Reformat pexpects These are now python scripts --- tests/pexpects/bind_mode_events.py | 4 +++- tests/pexpects/commandline.py | 10 +++++++--- tests/pexpects/complete.py | 14 +++++++++++--- tests/pexpects/exit.py | 24 ++++++++++++++++++------ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/tests/pexpects/bind_mode_events.py b/tests/pexpects/bind_mode_events.py index d0f262346..0cda01cef 100644 --- a/tests/pexpects/bind_mode_events.py +++ b/tests/pexpects/bind_mode_events.py @@ -10,7 +10,9 @@ expect_prompt() send("echo ready to go\r") expect_prompt("\r\nready to go\r\n") -send("function add_change --on-variable fish_bind_mode ; set -g MODE_CHANGES $MODE_CHANGES $fish_bind_mode ; end\r") +send( + "function add_change --on-variable fish_bind_mode ; set -g MODE_CHANGES $MODE_CHANGES $fish_bind_mode ; end\r" +) expect_prompt() # normal mode diff --git a/tests/pexpects/commandline.py b/tests/pexpects/commandline.py index 5d12f68de..2e2b70dc5 100644 --- a/tests/pexpects/commandline.py +++ b/tests/pexpects/commandline.py @@ -9,13 +9,17 @@ sendline("bind '~' 'handle_tilde'") expect_prompt() # printing the current buffer should not remove quoting -sendline("function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end") +sendline( + "function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end" +) 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") # printing the buffer with -o should remove quoting -sendline("function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end") +sendline( + "function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end" +) expect_prompt() sendline("echo one \"two three\" four'five six'{7} 'eight~") expect_prompt("\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n") diff --git a/tests/pexpects/complete.py b/tests/pexpects/complete.py index 71bdc8a80..0324c365e 100644 --- a/tests/pexpects/complete.py +++ b/tests/pexpects/complete.py @@ -2,10 +2,17 @@ from pexpect_helper import SpawnedProc sp = SpawnedProc() -send, sendline, sleep, expect_prompt, expect_re = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_re +send, sendline, sleep, expect_prompt, expect_re = ( + sp.send, + sp.sendline, + sp.sleep, + sp.expect_prompt, + sp.expect_re, +) expect_prompt() -sendline(""" +sendline( + """ complete -c my_is -n 'test (count (commandline -opc)) = 1' -xa arg complete -c my_is -n '__fish_seen_subcommand_from not' -xa '( set -l cmd (commandline -opc) (commandline -ct) @@ -13,7 +20,8 @@ sendline(""" commandline --replace --current-process $cmd complete -C"$cmd" )' -""") +""" +) send("my_is not \t") send("still.alive") diff --git a/tests/pexpects/exit.py b/tests/pexpects/exit.py index 9d4f996fe..8f3e6aba0 100644 --- a/tests/pexpects/exit.py +++ b/tests/pexpects/exit.py @@ -4,7 +4,13 @@ import subprocess import sys sp = SpawnedProc() -send, sendline, sleep, expect_prompt, expect_re = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_re +send, sendline, sleep, expect_prompt, expect_re = ( + sp.send, + sp.sendline, + sp.sleep, + sp.expect_prompt, + sp.expect_re, +) expect_prompt() # Verify that if we attempt to exit with a job in the background we get warned @@ -12,13 +18,15 @@ expect_prompt() send("sleep 111 &\r") expect_prompt() send("exit\r") -expect_re("""There are still jobs active:\r +expect_re( + """There are still jobs active:\r \r PID Command\r *\\d+ sleep 111 &\r \r A second attempt to exit will terminate them.\r -Use 'disown PID' to remove jobs from the list without terminating them.\r""") +Use 'disown PID' to remove jobs from the list without terminating them.\r""" +) expect_prompt() # Running anything other than `exit` should result in the same warning with @@ -26,20 +34,24 @@ expect_prompt() send("sleep 113 &\r") expect_prompt() send("exit\r") -expect_re("""There are still jobs active:\r +expect_re( + """There are still jobs active:\r \r PID Command\r *\\d+ sleep 113 &\r *\\d+ sleep 111 &\r \r A second attempt to exit will terminate them.\r -Use 'disown PID' to remove jobs from the list without terminating them.\r""") +Use 'disown PID' to remove jobs from the list without terminating them.\r""" +) expect_prompt() # Verify that asking to exit a second time does so. send("exit\r") -proc = subprocess.run(["pgrep", "-l", "-f", "sleep 11"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +proc = subprocess.run( + ["pgrep", "-l", "-f", "sleep 11"], stdout=subprocess.PIPE, stderr=subprocess.PIPE +) if proc.returncode == 0: print("Commands still running") print(proc.stdout)