mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-12 16:56:15 +01:00
behave: Add 'stderr is' step
This commit is contained in:
parent
59e7013cf2
commit
3faf01c862
@ -93,8 +93,8 @@ def step_impl(context, text):
|
||||
|
||||
@behave.step("stdout is")
|
||||
def step_impl(context):
|
||||
expected = context.text.format(context=context).rstrip().split('\n')
|
||||
found = context.cmd_stdout.rstrip().split('\n')
|
||||
expected = context.text.format(context=context).rstrip().split("\n")
|
||||
found = context.cmd_stdout.rstrip().split("\n")
|
||||
|
||||
if found == expected:
|
||||
return
|
||||
@ -104,6 +104,19 @@ def step_impl(context):
|
||||
raise AssertionError(f"Stdout is not:\n{expected_str}\n\nActual stdout:\n{found_str}")
|
||||
|
||||
|
||||
@behave.step("stderr is")
|
||||
def step_impl(context):
|
||||
expected = context.text.format(context=context).rstrip().split("\n")
|
||||
found = context.cmd_stderr.rstrip().split("\n")
|
||||
|
||||
if found == expected:
|
||||
return
|
||||
|
||||
expected_str = "\n".join(expected)
|
||||
found_str = "\n".join(found)
|
||||
raise AssertionError(f"Stderr is not:\n{expected_str}\n\nActual stderr:\n{found_str}")
|
||||
|
||||
|
||||
@behave.step('I set working directory to "{path}"')
|
||||
def step_impl(context, path):
|
||||
path = path.format(context=context)
|
||||
@ -183,7 +196,15 @@ def step_impl(context, path, mode):
|
||||
@behave.step("the exit code is {exitcode}")
|
||||
def the_exit_code_is(context, exitcode):
|
||||
if context.cmd_exitcode != int(exitcode):
|
||||
raise AssertionError(f"Command has exited with code {context.cmd_exitcode}: {context.cmd}")
|
||||
lines = [
|
||||
f"Command has exited with code {context.cmd_exitcode}: {context.cmd}",
|
||||
"> stdout:",
|
||||
context.cmd_stdout.strip(),
|
||||
"",
|
||||
"> stderr:",
|
||||
context.cmd_stderr.strip(),
|
||||
]
|
||||
raise AssertionError("\n".join(lines))
|
||||
context.cmd_exitcode_checked = True
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user