def addError(self, test, err): TestResult.addError(self, test, err) err = self._exc_info_to_string(err, test) self.messages.testError(self.getTestName(test), message='Error', details=err)
def _testrun(self): """ Start a Testrun and populate the Publishers @rtype: C{unittest.TestResult} @return: A TestResult """ testrun_result = TestResult() try: publishers = self._publishers testrun = Testrun(self.is_hw_enabled, self.is_host_enabled, self.is_chroot_enabled) taskrunner = self.taskrunner #FIXME: Cheap hack to make testable testrun.run_test = taskrunner.run testrun_result.addSuccess(TestCase)if testrun.run() else \ testrun_result.addFailure(TestCase, (None, None, None)) except Exception, err: er_type, value, traceback = sys.exc_info() LOG.error(str(value) or "Testrun Error", exc_info=err) publishers.set_exception(value) testrun_result.addError(TestCase, (er_type, value, traceback)) if DEBUG: raise
def addError(self, test, err, *k): TestResult.addError(self, test, err) err = self.formatErr(err) self.messages.testFailed(self.getTestName(test), message='Error', details=err)
def addError(self, test, err): testname = test.id().split(".")[-1] tb = err[2] stack = traceback.extract_tb(tb) for frame in stack: fname = frame[2] if fname == testname: if self._logging: self._writeToStream("\tResult: ") self._writeToStream("Test ERROR", eColors.Yellow) break if fname == "setUp": if self._logging: self._writeToStream("\tResult: ") self._writeToStream("SetUp ERROR", eColors.Yellow) break if fname == "tearDown": #If test succeded but tear down failed the result should #still be that the test failed. So it's my resposibility #to display thet only the 'test' part of the test passed. (Confused yet?) faults = chain(self.failures, self.errors) testFaults = ifilter(lambda item: item[0] == test, faults) hasFailed = (sum(1 for u in testFaults) > 0) if not hasFailed: if self._logging: self._writeToStream("\tResult: ") self._writeToStream("PASSED", eColors.Green) self._writeToStream(", ") self._writeToStream("Tear Down ERROR", eColors.Yellow) break TestResult.addError(self, test, err)
def addError(self, test, err): time_taken = time.time() - self._start_time TestResult.addError(self, test, err) (error, message, tb) = err stackstr = self._generate_stack(tb) self.stream.writeln("%%TEST_ERROR%% time=%.6f testname=%s message=%s location=%s" % (time_taken, self.getDescription(test), str(message).replace('\n', '%BR%'), stackstr))
def addError(self, test, err): """Called when an error has occurred.""" TestResult.addError(self, test, err) if self.verbose: self.stream.write('ERROR\n') else: self.stream.write('E') self.stream.flush()
def addError(self, test, err): TestResult.addError(self, test, err) exctype, value, dummy_tb = err error_xml = self.xml.createElement('error') error_xml.setAttribute('type', '%s' % exctype) message_xml = self.xml.createTextNode('%s' % value) error_xml.appendChild(message_xml) self._testcase_xml.appendChild(error_xml)
def addError(self, test, err): location = self.init_suite(test) self.current_failed = True TestResult.addError(self, test, err) err = self._exc_info_to_string(err, test) self.messages.testStarted(self.getTestName(test), location=location) self.messages.testError(self.getTestName(test), message="Error", details=err, duration=self.__getDuration(test))
def addError(self, test, err): self.error_count += 1 TestResult.addError(self, test, err) _, _exc_str = self.errors[-1] output = self.complete_output() self.result.append((2, test, output, _exc_str)) sys.stderr.write('Error ') sys.stderr.write(str(test)) sys.stderr.write('\n')
def addError(self, test, err): TestResult.addError(self, test, err) if err[0] is KeyboardInterrupt: self.shouldStop = 1 self._lastWas = 'error' self._errorsAndFailures += '<error type="%s">' % err[0].__name__ for line in apply(traceback.format_exception, err): for l in string.split(line,"\n")[:-1]: self._errorsAndFailures += "%s" % l self._errorsAndFailures += "</error>"
def addError(self, test, err): self.init_suite(test) self.current_failed = True TestResult.addError(self, test, err) err = self._exc_info_to_string(err, test) self.messages.testStarted(self.getTestName(test)) self.messages.testError(self.getTestName(test), message='Error', details=err)
def addError(self, test, err): location = self.init_suite(test) self.current_failed = True TestResult.addError(self, test, err) err = self._exc_info_to_string(err, test) self.messages.testStarted(self.getTestName(test), location=location) self.messages.testError(self.getTestName(test), message='Error', details=err, duration=self.__getDuration(test))
def addError(self, test, err): """ Method called if a test errored. @param test Reference to the test object @param err The error traceback """ TestResult.addError(self, test, err) tracebackLines = traceback.format_exception(*(err + (10,))) self.parent.write('{0}{1}\n'.format(ResponseUTTestErrored, str((str(test), tracebackLines))))
def addError(self, test, err): """ Method called if a test errored. @param test Reference to the test object @param err The error traceback """ TestResult.addError(self, test, err) tracebackLines = traceback.format_exception(*(err + (10,))) self.parent.write('%s%s\n' % (ResponseUTTestErrored, unicode((unicode(test), tracebackLines))))
def addError(self, test, err, *k): TestResult.addError(self, test, err) err = self.formatErr(err) if self.getTestName(test) != self.test_name: sys.stderr.write("INTERNAL ERROR: addError(%s) outside of test\n" % self.getTestName(test)) sys.stderr.write("Error: %s\n" % err) return self.messages.testFailed(self.getTestName(test), message='Error', details=err)
def addError(self, test, err): """ Public method called if a test errored. @param test Reference to the test object @param err The error traceback """ TestResult.addError(self, test, err) tracebackLines = self._exc_info_to_string(err, test) self.parent.write('{0}{1}\n'.format( ResponseUTTestErrored, str((str(test), tracebackLines, test.id()))))
def addError(self, test, err): self.error_count += 1 TestResult.addError(self, test, err) _exc_str = self.errors[-1][1] output = self.complete_output() self.result.append((2, test, output, _exc_str)) if self.verbosity > 1: sys.stderr.write("E ") sys.stderr.write(str(test)) sys.stderr.write("\n") else: sys.stderr.write("E")
def addError(self, test, err): """ Public method called if a test errored. @param test Reference to the test object @param err The error traceback """ TestResult.addError(self, test, err) tracebackLines = self._exc_info_to_string(err, test) self.parent.write( '%s%s\n' % (ResponseUTTestErrored, unicode((unicode(test), tracebackLines, test.id()))))
def addError(self, test, err): self.error_count += 1 TestResult.addError(self, test, err) _exc_str = self.errors[-1][1] output = self.complete_output() self.result.append((2, test, output, _exc_str)) if self.verbosity > 1: sys.stderr.write('E ') sys.stderr.write(str(test)) sys.stderr.write('\n') else: sys.stderr.write('E')
def addError(self, test, err): self.error_count += 1 TestResult.addError(self, test, err) _, _exc_str = self.errors[-1] self.resultSignal.emit((0, str(test))) print("\n<ERROR> occurred in {}, reason: {}\n".format(test, _exc_str)) self.clearWarnings(test) if self.verbosity > 1: sys.stderr.write('E ') sys.stderr.write(str(test)) sys.stderr.write('\n') else: sys.stderr.write('E')
def addError(self, test, err): exc, val, tb = err if not issubclass(exc, SkipTest): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: if issubclass(exc, SkipTest): self.stream.writeln("") self.stream.writeln("SKIP: %s" % nice_test_address(test)) else: self.printError('ERROR', err, test) self.stream.flush()
def addError(self, test, err): TestResult.addError(self, test, err) _, _exc_str = self.errors[-1] self._steams_write_doc("Error", test) logging.error((self.LANG == 'cn' and "测试产生错误: {}\n{}" or "Error Test: {}\n{}").format(test, _exc_str)) current_id = str(threading.current_thread().ident) self.result_tmp[current_id]["result_code"] = 2 self.result_tmp[current_id]["style"][self.result_tmp[current_id]['tries']] = 2 if current_id not in self.error_set: self.error_count += 1 self.error_set.add(current_id)
def addError(self, test, err): """ Public method called if a test errored. @param test Reference to the test object @param err The error traceback """ TestResult.addError(self, test, err) tracebackLines = self._exc_info_to_string(err, test) self.__dbgClient.sendJsonCommand("ResponseUTTestErrored", { "testname": str(test), "traceback": tracebackLines, "id": test.id(), })
def addError(self, test, err): TestResult.addError(self,test, err) file_name = getattr(self.stream,"name") if self.showAll: self.stream.writeln("ERROR") elif self.dots: self.stream.write('E') error = TestResult._exc_info_to_string(self,err,test) log.error("#" * 50) log.error("%s errored out." % test._testMethodName) if "setUp" in test._testMethodName: print "Testsuite aborted in setUp itself." log.error("#" * 50) if "stdout" not in file_name: log.error("\n\n%s"%error)
def run(self, result: TestResult, debug=False): name = f"{self._server.protocol:<10} : {self._server.name:<20} server" server_test = DummyTestForServer( self._server, f"{name} starting ") result.startTest(server_test) try: with self._server.with_running(): result.addSuccess(server_test) super().run(result, debug=debug) server_test = DummyTestForServer( self._server, f"{name} stopping ") result.startTest(server_test) result.addSuccess(server_test) except Exception as e: exc_info = sys.exc_info() result.addError(server_test, exc_info)
def addError(self, test, err): """添加错误信息 Arguments: test -- [测试用例] exec_info -- [异常信息] """ TestResult.addError(self, test, err) self.error_count += 1 self.details.append({"className": '.'.join(test.id().split('.')[:-1]), \ "methodName": test._testMethodName, \ "description": test._testMethodDoc, \ "spendTime": 0, \ "status": self.status[self.lan]["Error"], \ "log": self._exc_info_to_string(err, test) \ .replace("\n", "<br/>")}\ )
def addError(self, test, err): TestResult.addError(self, test, err) _, _exc_str = self.errors[-1] self.stderr_steams.write('Error\t') self.stderr_steams.write(str(test)) doc = test._testMethodDoc if doc: self.stderr_steams.write("\t") self.stderr_steams.write(doc) self.stderr_steams.write('\n') GeneralLogger().get_logger().error( (self.LANG == 'cn' and "测试产生错误: {}\n{}" or "Error Test: {}\n{}").format(test, _exc_str)) current_id = str(threading.current_thread().ident) self.result_tmp[current_id]["result_code"] = 2 if current_id not in self.error_set: self.error_count += 1 self.error_set.add(current_id)
def run(self): """ Start a Testrun and publish the data @rtype: C{unittest.TestResult} @return: A TestResult """ if sandbox.exc_info != (None, None, None): LOG.error("Testrun Error. Forced Initialisation", \ exc_info = sandbox.exc_info) etype, value, traceback = sandbox.exc_info testrun_result = TestResult() testrun_result.addError(TestCase, (etype, value, traceback)) self._publishers.set_exception(value) sandbox.exc_info = (None, None, None) else: testrun_result = self._testrun() result_string = result_to_string(testrun_result) LOG.info("Result set to %s"%(result_string)) self._publishers.set_testrun_result(result_string) self._publishers.publish() LOG.info("Testrun finished with result: %s" % result_string) return testrun_result
def run(self): """ Start a Testrun and publish the data @rtype: C{unittest.TestResult} @return: A TestResult """ if sandbox.exc_info != (None, None, None): LOG.error("Testrun Error. Forced Initialisation", \ exc_info = sandbox.exc_info) etype, value, traceback = sandbox.exc_info testrun_result = TestResult() testrun_result.addError(TestCase, (etype, value, traceback)) self._publishers.set_exception(value) sandbox.exc_info = (None, None, None) else: testrun_result = self._testrun() result_string = result_to_string(testrun_result) LOG.info("Result set to %s" % (result_string)) self._publishers.set_testrun_result(result_string) self._publishers.publish() LOG.info("Testrun finished with result: %s" % result_string) return testrun_result
def addError(self, test, err): TestResult.addError(self, test, err) self.issue(test, err)
def addError(self, test, err): TestResult.addError(self, test, err) logger.setLogOff() logger.error("ERROR".center(20, "*")) logger.error(traceback.format_exc(5)) logger.error("ERROR".center(20, "*"))
def addError(self, test, err): TestResult.addError(self, test, err) self.logger.debug("ERROR")
def addError(self, test, err): _TestResult.addError(self, test, err) self.printFail(test, err) self.stream.writeln("ERROR: {0}".format(self.getDescription(test))) self.stream.writeln(self.errors[-1][1])
def addError(self, test, err): UnitTestResult.addError(self, test, err) if self.showAll: self._errWrite('ERROR\n') elif self.dots: self._errWrite('E')
def addError(self, test, err): _TestResult.addError(self, test, err) self.printFail(test, err)
def addError(self, test, err): TestResult.addError(self, test, err) self._color_print("ERROR", RED, bold=True)
def addError(self, test, err): TestResult.addError(self, test, err) for listener in self.listeners: listener.addError(test, err)
def addError(self, test, err): TestResult.addError(self, test, err) if self.verbose: self.stream.write("ERROR: %s%s" % (test, os.linesep)) self.stream.flush() self.countcall()
def addError(self, test, err): TestResult.addError(self, test, err) self.stream.writeln(hilite("ERROR", RED, bold=True))
def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.write_message("ERROR") elif self.dots: self.stream.write_message('E')
def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln(self.err_string) elif self.dots: self.stream.write('E')
def addError(self, test, err): TestResult.addError(self, test, err)
def addError(self, test, err): TestResult.addError(self, test, err) if not self.iterations: self.stream.write("ERR\n")
def addError(self, test, err): self.results_log[test.id()][1] = format_exc() self.update_logs(test.id(), self.erred, test.note_log, err) return TestResult.addError(self, test, err)
def _addError(self, test, err): TestResult.addError(self, test, err) self.stream.writeln( "{ERROR}" )