def report(self, autocolor=True):
total = 0
errors = []
for r in self.traversal:
total += 1
if r.is_leaf_error():
exc = r.exception[1]
indent = " "
if getattr(exc, "report_traceback", True):
tb = "\n\n" + r.get_traceback().strip()
errors.append("%s%s: unexpected error%s" % (indent, r.executor.name,
tb.replace("\n", "\n " + indent)))
else:
errors.append("%s%s: %s" % (indent, r.executor.context, exc))
if autocolor:
if errors:
color = self.terminal.bold_red
else:
color = self.terminal.green
else:
color = lambda x: x
result = "\n".join(["%s tasks run, %s errors" % (total, len(errors))] + errors)
return "\n".join([color(line) for line in result.splitlines()])
评论列表
文章目录