def get_row_data( self, row_comparison, columns, include_columns=None, exclude_columns=None, display_index=False, ): """Return single row data to be printed""" result = [] for idx, column in enumerate(columns): actual = row_comparison.data[idx] other, matched = row_comparison.get_comparison_value(column, idx) value_limit = int((constants.CELL_STRING_LENGTH - 4) / 2) other, actual = format_cell_data(data=[other, actual], limit=value_limit) include_columns = include_columns or columns exclude_columns = exclude_columns or [] if (column not in include_columns) or (column in exclude_columns): result.append("{} .. {}".format(actual, other)) elif matched: result.append(Color.green("{} == {}".format(actual, other))) else: result.append(Color.red("{} != {}".format(actual, other))) if display_index: result = [row_comparison.idx] + result return result
def get_assertion_details(self, entry): """ `RegexMatchLine` returns line indexes along with begin/end character indexes per matched line. """ pattern = "Pattern: `{}`{}".format(entry.pattern, os.linesep) if entry.match_indexes: parts = [] match_map = { line_no: (begin, end) for line_no, begin, end in entry.match_indexes } for idx, line in enumerate(entry.string.splitlines()): if idx in match_map: begin, end = match_map[idx] parts.append( line[:begin] + Color.green(line[begin:end]) + line[end:] ) else: parts.append(line) return "{}{}".format(pattern, os.linesep.join(parts)) return "{}{}".format(pattern, entry.string)
def log_test_status(self, name, passed, indent=0, level=TEST_INFO): """Shortcut to log a pass/fail status for a test.""" pass_label = Color.green('Pass') if passed else Color.red('Fail') indent_str = indent * ' ' msg = self._TEST_STATUS_FORMAT self._custom_log( level, msg, {'name': name, 'pass_label': pass_label, 'indent': indent_str})
def _print_test_result(self, task_result): if not isinstance(task_result.result, RunnableResult) or\ not hasattr(task_result.result, 'report'): return # Currently prints report top level result and not details. name = task_result.result.report.name if task_result.result.report.passed is True: self.logger.test_info('{} -> {}'.format(name, Color.green('Pass'))) else: self.logger.test_info('{} -> {}'.format(name, Color.red('Fail')))
def _print_test_result(self, task_result): if (not isinstance(task_result.result, entity.RunnableResult)) or ( not hasattr(task_result.result, "report")): return # Currently prints report top level result and not details. name = task_result.result.report.name if task_result.result.report.passed is True: self.logger.test_info("{} -> {}".format(name, Color.green("Pass"))) else: self.logger.test_info("{} -> {}".format(name, Color.red("Fail")))
def log_test_status(self, name, status, indent=0, level=TEST_INFO): """Shortcut to log a pass/fail status for a test.""" if Status.STATUS_CATEGORY[status] == Status.PASSED: pass_label = Color.green(status.title()) elif Status.STATUS_CATEGORY[status] in [Status.FAILED, Status.ERROR]: pass_label = Color.red(status.title()) elif Status.STATUS_CATEGORY[status] == Status.UNSTABLE: pass_label = Color.yellow(status.title()) else: # unknown pass_label = status indent_str = indent * " " msg = self._TEST_STATUS_FORMAT self._custom_log( level, msg, { "name": name, "pass_label": pass_label, "indent": indent_str }, )
def pass_label(self, entry): return Color.green("Pass") if entry else Color.red("Fail")
def pass_label(self, entry): return Color.green('Pass') if entry else Color.red('Fail')
def get_test_status_message(name, passed): pass_label = Color.green('Pass') if passed else Color.red('Fail') return TEST_STATUS_FORMAT.format(name=name, pass_label=pass_label)