def step_command_output_should_contain(context): ''' EXAMPLE: ... when I run "behave ..." then it should pass and the command output should contain: """ TEXT """ ''' assert context.text is not None, "ENSURE: multiline text is provided." expected_output = context.text if "{__WORKDIR__}" in expected_output or "{__CWD__}" in expected_output: expected_output = context.text.format( __WORKDIR__ = command_util.posixpath_normpath(context.workdir), __CWD__ = command_util.posixpath_normpath(os.getcwd()) ) command_output = context.command_result.output expected_output = command_util.text_normalize(expected_output.strip()) actual_output = command_util.text_normalize(command_output.strip()) if DEBUG: print("expected:\n{0}".format(expected_output)) print("actual:\n{0}".format(actual_output)) assert_that(actual_output, contains_string(expected_output))
def step_command_output_should_not_contain_text(context, text): ''' EXAMPLE: ... then the command output should not contain "TEXT" ''' text = text.format(__WORKDIR__=command_util.posixpath_normpath( context.workdir), __CWD__=command_util.posixpath_normpath(os.getcwd())) command_output = context.command_result.output expected_output = command_util.text_normalize(text) actual_output = command_util.text_normalize(command_output.strip()) if DEBUG: print("expected:\n{0}".format(expected_output)) print("actual:\n{0}".format(actual_output)) assert_that(actual_output, is_not(contains_string(expected_output)))
def step_command_output_should_not_contain_text(context, text): ''' EXAMPLE: ... then the command output should not contain "TEXT" ''' text = text.format( __WORKDIR__ = command_util.posixpath_normpath(context.workdir), __CWD__ = command_util.posixpath_normpath(os.getcwd()) ) command_output = context.command_result.output expected_output = command_util.text_normalize(text) actual_output = command_util.text_normalize(command_output.strip()) if DEBUG: print("expected:\n{0}".format(expected_output)) print("actual:\n{0}".format(actual_output)) assert_that(actual_output, is_not(contains_string(expected_output)))
def step_command_output_should_contain(context): ''' EXAMPLE: ... when I run "behave ..." then it should pass and the command output should contain: """ TEXT """ ''' assert context.text is not None, "ENSURE: multiline text is provided." expected_output = context.text if "{__WORKDIR__}" in expected_output or "{__CWD__}" in expected_output: expected_output = context.text.format( __WORKDIR__=command_util.posixpath_normpath(context.workdir), __CWD__=command_util.posixpath_normpath(os.getcwd())) command_output = context.command_result.output expected_output = command_util.text_normalize(expected_output.strip()) actual_output = command_util.text_normalize(command_output.strip()) if DEBUG: print("expected:\n{0}".format(expected_output)) print("actual:\n{0}".format(actual_output)) assert_that(actual_output, contains_string(expected_output))