elif data["status"] == "SKIP": result = ElementTree.SubElement(test, "skipped") self.skips += 1 def test_status(self, data): self._create_result(data) def test_end(self, data): self._create_result(data) def suite_end(self, data): self.root.attrib.update({ "tests": str(self.tests_run), "errors": str(self.errors), "failures": str(self.failures), "skiped": str(self.skips), "time": "%.2f" % ((data["time"] - self.suite_start_time) / 1000) }) return ElementTree.tostring(self.root, encoding="utf8") if __name__ == "__main__": base.format_file( sys.stdin, handlers.StreamHandler(stream=sys.stdout, formatter=XUnitFormatter()))
t = self.terminal.blue(format_seconds(self._time(entry))) return '%s %s' % (t, self._colorize(entry, s)) def _colorize(self, data, s): if self.terminal is None: return s subtests = self._get_subtest_data(data) color = None len_action = len(data["action"]) if data["action"] == "test_end": if "expected" not in data and subtests["unexpected"] == 0: color = self.terminal.green else: color = self.terminal.red elif data["action"] in ("suite_start", "suite_end", "test_start"): color = self.terminal.yellow if color is not None: result = color(s[:len_action]) + s[len_action:] return result if __name__ == "__main__": base.format_file(sys.stdin, handlers.StreamHandler(stream=sys.stdout, formatter=MachFormatter()))