Skip to content

Commit

Permalink
psh: apply black formatting to test-kill
Browse files Browse the repository at this point in the history
JIRA: CI-415
  • Loading branch information
damianloew committed Feb 26, 2024
1 parent c55eb07 commit e275b3d
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions psh/test-kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,50 @@

def assert_kill_procs(p, pid_list):
for pid in pid_list:
msg = f'Wrong output when killing process with the following pid: {pid}'
psh.assert_cmd(p, f'kill {pid}', result='dont-check', msg=msg)
msg = f"Wrong output when killing process with the following pid: {pid}"
psh.assert_cmd(p, f"kill {pid}", result="dont-check", msg=msg)

sleep(0.5)

dead = set(pid_list) - set(proc['pid'] for proc in get_process_list(p))
assert len(dead) == len(pid_list), f'failed to kill {len(pid_list) - len(dead)} processes out of {len(pid_list)}'
dead = set(pid_list) - set(proc["pid"] for proc in get_process_list(p))
assert len(dead) == len(
pid_list
), f"failed to kill {len(pid_list) - len(dead)} processes out of {len(pid_list)}"


def assert_errors(p):
unused_pid = max(int(proc["pid"]) for proc in get_process_list(p)) + 1

# nothing should be done
msg = 'Wrong output when killing nonexistent process'
psh.assert_cmd(p,
f'kill {unused_pid}',
expected=rf'(kill: failed to send signal to process \d+?{psh.EOL})|{psh.EOL}',
result="fail",
msg=msg,
is_regex=True)

msg = 'Wrong kill help message'
psh.assert_cmd(p, 'kill',
expected=rf'(kill: |)(u|U)sage: kill[^\r]+?{psh.EOL}',
result='fail',
msg=msg,
is_regex=True)

msg = 'Wrong kill error message when passing string in argument'
psh.assert_cmd(p, 'kill not_number',
expected=rf'kill: [^\r]+?{psh.EOL}',
result='fail',
msg=msg,
is_regex=True)
msg = "Wrong output when killing nonexistent process"
psh.assert_cmd(
p,
f"kill {unused_pid}",
expected=rf"(kill: failed to send signal to process \d+?{psh.EOL})|{psh.EOL}",
result="fail",
msg=msg,
is_regex=True,
)

msg = "Wrong kill help message"
psh.assert_cmd(
p,
"kill",
expected=rf"(kill: |)(u|U)sage: kill[^\r]+?{psh.EOL}",
result="fail",
msg=msg,
is_regex=True,
)

msg = "Wrong kill error message when passing string in argument"
psh.assert_cmd(
p,
"kill not_number",
expected=rf"kill: [^\r]+?{psh.EOL}",
result="fail",
msg=msg,
is_regex=True,
)


@psh.run
Expand Down

0 comments on commit e275b3d

Please sign in to comment.