def addSuccess(self, test): "Called when a test has completed successfully" super(XunitTestResult, self).addSuccess(test) cls, name = id_split(test.id()) ET.SubElement(self.testsuite, 'testcase', classname=cls, name=name, taken="%.3f" % self._time_taken())
def _add_failure(self, test, err): cls, name = id_split(test.id()) def get_log(): with open(test.meta.logname) as reader: content = reader.read() content = content.replace('\r', '\n').replace('\x00', '') content = SHELL_COLOR_PATTERN.sub('', content) return content.decode('utf8', 'ignore') if hasattr(test, 'meta'): content = get_log() else: content = "Log file isn't available!" testcase = ET.SubElement(self.testsuite, 'testcase', classname=cls, name=name, time="%.3f" % self._time_taken()) failure = ET.SubElement(testcase, 'failure', message=str(err)) failure.text = content