def run_test(self, parameters): """ Run a Click PlaybookRunner test case. :param parameters: a TestCaseParameters instance """ result = CliRunner().invoke(cli=oct_command, args=parameters.args) extra = 'Full output:\n{}'.format(result.output) if result.exception is not None: extra = ''.join(format_exception(*result.exc_info)) self.assertEqual( parameters.expected_result, result.exit_code, format_assertion_failure( message='Command did not exit with correct code.', expectation=(parameters.expected_result, result.exit_code), extra=extra)) self.validate_call_metadata(parameters.expected_calls) if parameters.expected_output is not None: self.assertIn( parameters.expected_output, result.output, msg=format_assertion_failure( message='Phrase `{}` not found in output.'.format( parameters.expected_output), extra=extra))
def make_equality_assertion(self, actual, expected, message): """ Make an assertion about equality, with a nice error message that is consistent between tests and gives full context to what is being tested. :param actual: object :param expected: object :param message: failure message """ self.assertEqual(actual, expected, msg=format_assertion_failure( message=message, expectation=(actual, expected), extra='Full Call Metadata Context:\n{}'.format( format_expectation(self._call_metadata, self._expected_calls))))