Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-bloch committed Aug 11, 2023
1 parent 9a37658 commit 8127423
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion psh/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The python module `psh` makes writing harness tests easier. It provides the foll

* `assert_prompt_after_cmd(pexpect_proc, cmd, result='success', msg=None)` - Sends a command and asserts only `EOL` and next prompt. This method can be useful, when expecting command's output is not needed. Sent command isn't also asserted, so this function can be used for sending some unprintable characters. If it does not fail, the output caught before prompt will be returned. If the `msg` argument is not passed, the default error message will be used. The function also checks the exit code of a passed command in the same way as `assert_cmd()`.

* `assert_prompt(pexpect_proc, msg='', timeout=-1, catch_timeout=True)` - Asserts psh prompt. There is also a possibility to pass a message to print if the assertion fails and set timeout arguments.
* `assert_prompt(pexpect_proc, msg='', timeout=-1, catch_timeout=True)` - Asserts psh prompt by searching only for `'(psh)% '` in buffer (without checking an escape sequence). There is also a possibility to pass a message to print if the assertion fails and set timeout arguments.

* `assert_prompt_fail(pexpect_proc, msg='', timeout=-1)` - Asserts that there is no psh prompt in the read buffer.

Expand Down
8 changes: 4 additions & 4 deletions psh/tools/psh.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ def assert_prompt_after_cmd(pexpect_proc, cmd, result='success', msg=None):


def assert_prompt(pexpect_proc, msg='', timeout=-1, catch_timeout=True):
patterns = [PROMPT]
patterns = ['(psh)% ']
if catch_timeout:
patterns.append(pexpect.TIMEOUT)

idx = pexpect_proc.expect(patterns, timeout=timeout)
idx = pexpect_proc.expect_exact(patterns, timeout=timeout)
# if catch_timeout is false then pyexpect exception is raised
assert idx == 0, msg


def assert_prompt_fail(pexpect_proc, msg='', timeout=-1):
patterns = [PROMPT, pexpect.TIMEOUT, pexpect.EOF]
idx = pexpect_proc.expect(patterns, timeout=timeout)
patterns = ['(psh)% ', pexpect.TIMEOUT, pexpect.EOF]
idx = pexpect_proc.expect_exact(patterns, timeout=timeout)
assert idx != 0, msg


Expand Down

0 comments on commit 8127423

Please sign in to comment.