def reportError(self, test, err): name, classname = self.getTestNames(test) self.xml.write(' <testcase name="%s" classname="%s">\n' % (name, classname)) self.xml.write(' <failure message=" "/>\n') self.xml.write(' </testcase>\n') sys.stderr.write("%s %s.%s\n" % (failStr('[ FAILED ]'), classname, name)) self.testFailed += 1
def closeXmlReport(self): self.xml.write('</testsuite>\n') self.xml.close() print >> sys.stderr, greenLowStr("[==========]") + " run %d tests\n" % self.numberTests if (self.testFailed): print >> sys.stderr, failStr("[ FAILED ]") + " %d tests\n" % self.testFailed else: print >> sys.stderr, greenLowStr("[ PASSED ]") + " %d tests\n" % (self.numberTests - self.testFailed)
def printLog(msg, log=None, out=True, err=False, isError=False): '''Just print a msg in the log''' from protlib_xmipp import failStr, findColor if not log is None: if isError: log.error(failStr(msg)) else: log.info(msg) if out or err: if isError: color_tuple = findColor(msg) if not color_tuple is None: msg = color_tuple[3] msg = failStr("ERROR: "+ msg) msg = getLogMessage(msg) if out: print msg sys.stdout.flush() if err: print >> sys.stderr, msg sys.stderr.flush()
def reportError(msg): from protlib_xmipp import failStr '''Function to write error message to stderr and raise an Exception''' print >> sys.stderr, failStr("ERROR: %s" % msg) raise Exception(msg)