def wrapper(self, **kwargs): queue = func(self, **kwargs) a = queue.next() b = queue.next() expected = queue.next() a = dedent(a).strip() b = dedent(b).strip() actual = [i for i in describe_diff(a, b)] if not expected == actual: # pragma: no cover self.fail('Diff does not match:\nexpected\n{}\nactual\n{}'.format( pp(expected), pp(actual)))
def dumps(self, verbose=False): """ Formats a list of test results to unicode. The reporter can also output the value of what was sent to stdin and what the plugin sent to stdout if ``verbose`` is ``True``. """ out = [] results = self.results for result in results: exprange = result.expectation.range v_out = [] if verbose: self._add_verbosity(v_out, result.stdin, result.stdout) if isinstance(result, SuccessResult): out.append( green_bold(u'{0:02d} – {1:02d} Pass'.format( exprange[0], exprange[1]))) out.append(u'') out.extend(v_out) continue out.append( red_bold(u'{0:02d} – {1:02d} Fail'.format( exprange[0], exprange[1]))) out.extend(v_out) out.append(u'') out.append(u'Actual') out.append(REPORTER_HORIZONTAL_DIVIDER) out.append(u'') out.extend(result.actual.splitlines()) out.append(u'') out.append(u'Diff') out.append(REPORTER_HORIZONTAL_DIVIDER) out.append(u'') diff = describe_diff(result.expectation.output, result.actual) for (_, diff_type, line) in diff: if diff_type == '-': decorator = red_bold elif diff_type == '+': decorator = green_bold else: # No operation but return decorator = lambda a: a out.append(decorator(u'{0} {1}'.format(diff_type, line))) out.append(u'') pass_count = len([i for i in results if isinstance(i, SuccessResult)]) fail_count = len([i for i in results if isinstance(i, FailureResult)]) out.append(u'Pass {0}, Fail {1}'.format(pass_count, fail_count)) return u'\n'.join(out)
def dumps(self, verbose=False): """ Formats a list of test results to unicode. The reporter can also output the value of what was sent to stdin and what the plugin sent to stdout if ``verbose`` is ``True``. """ out = [] results = self.results for result in results: exprange = result.expectation.range v_out = [] if verbose: self._add_verbosity(v_out, result.stdin, result.stdout) if isinstance(result, SuccessResult): out.append(green_bold(u'{0:02d} – {1:02d} Pass'.format( exprange[0], exprange[1]))) out.append(u'') out.extend(v_out) continue out.append(red_bold(u'{0:02d} – {1:02d} Fail'.format( exprange[0], exprange[1]))) out.extend(v_out) out.append(u'') out.append(u'Actual') out.append(REPORTER_HORIZONTAL_DIVIDER) out.append(u'') out.extend(result.actual.splitlines()) out.append(u'') out.append(u'Diff') out.append(REPORTER_HORIZONTAL_DIVIDER) out.append(u'') diff = describe_diff(result.expectation.output, result.actual) for (_, diff_type, line) in diff: if diff_type == '-': decorator = red_bold elif diff_type == '+': decorator = green_bold else: # No operation but return decorator = lambda a: a out.append(decorator(u'{0} {1}'.format(diff_type, line))) out.append(u'') pass_count = len([i for i in results if isinstance(i, SuccessResult)]) fail_count = len([i for i in results if isinstance(i, FailureResult)]) out.append(u'Pass {0}, Fail {1}'.format(pass_count, fail_count)) return u'\n'.join(out)