Beispiel #1
0
    def addFailure(self, test, err, capt=None, tb_info=None):
        id = test.id()
        tb = format_exception(err, self.encoding)
        self.stats['fail'] += 1
        try:
            (modulename, classname, testname) = id.split('.')
        except Exception as e:
            autopsy_logger.error("ID: " + str(id))
            autopsy_logger.error(e.message)
            return

        #     autopsy_logger.error("REASON: " + format_exception(err, self.encoding))
        autopsy_logger.error("===========================================")
        autopsy_logger.error("|      Test Failed : " + classname + "." +
                             testname)
        autopsy_logger.error("===========================================")
        timetaken = self._timeTaken()
        # autopsy_logger.info(timetaken)
        self.total_run_time += timetaken

        if autopsy_globals.test_fail_reason.find("\n") != -1:
            autopsy_globals.test_fail_reason = autopsy_globals.test_fail_reason[0:autopsy_globals.test_fail_reason.find("\n")]\
                .strip()

        self.report_string += "\n|{:<40}|{:^10}|{:^20}|{:<86}|"\
            .format("    " + classname + ("" if testname.strip() == "test" else "." + testname), "FAIL", self.nice_to_see_time(timetaken),
                    "   " + autopsy_globals.test_fail_reason.strip())

        self.fail_report_string += '\n' + "#" * 50 + '\n'
        self.fail_report_string += '\nTest Case    : ' + classname + "." + testname
        self.fail_report_string += '\nDescription  : \n' + self.reindent(
            self.currTestDescription, 5)
        self.fail_report_string += '\nSteps : \n' + self.reindent(
            self.dumpTestSteps(), 5)
        self.fail_report_string += '\nFail Reason  : \n' + self.reindent(
            format_exception(err, self.encoding), 5)

        if "test" == testname:
            testcase = self.getTestByName(classname)
            testcase.result = "Failed"
            autopsy_globals.dumpTestCaseJsonFile()

        else:
            testcase = self.getTestByName(classname + "." + testname)
            testcase.result = "Failed"
            autopsy_globals.dumpTestCaseJsonFile()

        if is_pause_on_fail():
            autopsy_logger.info(
                "Pausing the test run as pause on fail file found")
            pdb.set_trace()
    def addError(self, test, err, capt=None):
        """Add error output to Xunit report.
        """
        taken = self._timeTaken()

        if issubclass(err[0], SkipTest):
            type = 'skipped'
            self.stats['skipped'] += 1
        else:
            type = 'error'
            self.stats['errors'] += 1

        tb = format_exception(err, self.encoding)
        id = test.id()

        self.errorlist.append(
            u'<testcase classname=%(cls)s name=%(name)s time="%(taken).3f">'
            u'<%(type)s type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]>'
            u'</%(type)s>%(systemout)s%(systemerr)s</testcase>' %
            {'cls': self._quoteattr(id_split(id)[0]),
             'name': self._quoteattr(id_split(id)[-1]),
             'taken': taken,
             'type': type,
             'errtype': self._quoteattr(nice_classname(err[0])),
             'message': self._quoteattr(exc_message(err)),
             'tb': escape_cdata(tb),
             'systemout': self._getCapturedStdout(),
             'systemerr': self._getCapturedStderr(),
             })
Beispiel #3
0
    def addError(self, test, err, capt=None):
        """Add error output to Xunit report.
        """

        if issubclass(err[0], SkipTest):
            type = 'skipped'
            self.stats['skipped'] += 1
        else:
            type = 'error'
            self.stats['errors'] += 1

        tb = format_exception(err, self.encoding)
        id = test.id()

        testcase = self.buildTestcaseTag(test)

        self.errorlist.append(
            u'<%(testcase)s>'
            u'<%(type)s type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]>'
            u'</%(type)s>%(systemout)s%(systemerr)s</testcase>' % {
                'testcase': testcase,
                'type': type,
                'errtype': self._quoteattr(nice_classname(err[0])),
                'message': self._quoteattr(exc_message(err)),
                'tb': escape_cdata(tb),
                'systemout': self._getCapturedStdout(),
                'systemerr': self._getCapturedStderr(),
            })
Beispiel #4
0
    def addError(self, test, err, capt=None):
        """Add error output to Xunit report.
        """
        taken = self._timeTaken()

        if issubclass(err[0], SkipTest):
            _type = 'skipped'
            self.stats['skipped'] += 1
        else:
            _type = 'errors'
            self.stats['errors'] += 1

        tb = format_exception(err, self.encoding)
        _id = test.id()

        self.errorlist.append({
            'failed': True,
            'class': id_split(_id)[0],
            'name': id_split(_id)[-1],
            'time': str(datetime.timedelta(seconds=taken)),
            'type': _type,
            'exception': nice_classname(err[0]),
            'message': exc_message(err),
            'tb': tb,
            'stdout': self._getCapturedStdout(),
            'stderr': self._getCapturedStderr(),
            'shortDescription': test.shortDescription(),
        })
Beispiel #5
0
 def addError(self, test, err):
     self.send_result({
         'name': str(test),
         'status': 'error',
         'traceback': format_exception(err),
         'stdout': self._getCapturedStdout(),
         'stderr': self._getCapturedStderr(),
     })
Beispiel #6
0
 def __propagate_capture(self, log_level, cap_type, test, err):
     """
     Common routine to recover capture data and asking logging to
     deal with it nicely.
     """
     tb = format_exception(err, self.encoding)
     sout = self.__get_captured_stdout()
     serr = self.__get_captured_stderr()
     self.__call_all_plugin_by_attr('handle_capture', log_level, cap_type, test, sout, serr, tb)
Beispiel #7
0
 def __propagate_capture(self, log_level, cap_type, test, err):
     """
     Common routine to recover capture data and asking logging to
     deal with it nicely.
     """
     tb = format_exception(err, self.encoding)
     sout = self.__get_captured_stdout()
     serr = self.__get_captured_stderr()
     self.__call_all_plugin_by_attr('handle_capture', log_level, cap_type, test, sout, serr, tb)
Beispiel #8
0
    def addError(self, test, err, capt=None):
        id = test.id()
        self.stats['error'] += 1
        try:
            (modulename, classname, testname) = id.split('.')
        except Exception as e:
            autopsy_logger.error("ID: " + str(id))
            autopsy_logger.error(e.message)
            return

        autopsy_logger.error("REASON: " + format_exception(err, self.encoding))
        autopsy_logger.error("===========================================")
        autopsy_logger.error("|      Test Errored : " + classname + "." +
                             testname)
        autopsy_logger.error("===========================================")
        timetaken = self._timeTaken()
        self.total_run_time += timetaken

        if autopsy_globals.test_fail_reason.find("\n") != -1:
            autopsy_globals.test_fail_reason = autopsy_globals.test_fail_reason[0:autopsy_globals.test_fail_reason.find("\n")]\
                .strip()

        self.report_string += "\n|{:<40}|{:^10}|{:^20}|{:<86}|"\
            .format("    " + classname + ("" if testname.strip() == "test" else "." + testname), "ERROR", self.nice_to_see_time(timetaken),
                    "   " + autopsy_globals.test_fail_reason.strip())

        self.err_report_string += '\n' + "#" * 50 + '\n'
        self.err_report_string += '\nTest Case    : ' + classname + "." + testname
        self.err_report_string += '\nDescription  : \n' + self.reindent(
            self.currTestDescription, 5)
        self.err_report_string += '\nSteps : \n' + self.reindent(
            self.dumpTestSteps(), 5)
        self.err_report_string += '\nErr Reason   : \n' + self.reindent(
            format_exception(err, self.encoding), 5)

        if "test" == testname:
            testcase = self.getTestByName(classname)
            testcase.result = "Errored"
            autopsy_globals.dumpTestCaseJsonFile()
        else:
            testcase = self.getTestByName(classname + "." + testname)
            testcase.result = "Errored"
            autopsy_globals.dumpTestCaseJsonFile()
Beispiel #9
0
 def addFailure(self, test, err, capt=None, tb_info=None):
     """Add failure to the report.
     """
     time_taken = self.time_taken()
     self.result['summary']['failures'] += 1
     result = dict()
     trace_back = format_exception(err, 'UTF-8')
     result['time'] = time_taken
     result['id'] = test.id()
     result['details'] = {'message': trace_back}
     result['status'] = 'failed'
     self.result['testcases'].append(result)
Beispiel #10
0
    def addFailure(self, test, err, capt=None, tb_info=None):
        """Add failure output to Xunit report.
        """
        tb = format_exception(err, self.encoding)
        self.stats['failures'] += 1

        testcase = self.buildTestcaseTag(test)
        self.errorlist.append(
            u'<%(testcase)s>'
            u'<failure type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]>'
            u'</failure>%(systemout)s%(systemerr)s</testcase>' % {
                'testcase': testcase,
                'errtype': self._quoteattr(nice_classname(err[0])),
                'message': self._quoteattr(exc_message(err)),
                'tb': escape_cdata(tb),
                'systemout': self._getCapturedStdout(),
                'systemerr': self._getCapturedStderr(),
            })
Beispiel #11
0
    def addError(self, test, err):
        """Add error to the report.
        """
        time_taken = self.time_taken()
        result = dict()
        trace_back = format_exception(err, self.encode)
        if (err[0].__name__ == 'SkipTest'):
            self.result['summary']['skip'] += 1
            result['status'] = 'skipped'
            trace_back = trace_back.replace('Exception', 'SkipTest')
        else:
            self.result['summary']['errors'] += 1
            result['status'] = 'errored'

        result['time'] = time_taken
        result['id'] = test.id()
        result['details'] = {'message': trace_back}
        self.result['testcases'].append(result)
Beispiel #12
0
 def addFailure(self, test, err, capt=None, tb_info=None):
     elk = CTRexScenario.elk 
     if elk:
         taken = self._timeTaken()
         tb = format_exception(err, self.encoding)
         id = test.id()
         err_msg="TB : \n"+tb+"\n\n STDOUT:"+ self._getCapturedStdout()+self._getCapturedStderr();
         name=id_split(id)[-1]
         elk_obj = trex_scenario.copy_elk_info ()
         elk_obj['test']={ 
                    "name"   : name,
                    "name_key"   : name,
                    "name_full"  : id,
                     "type"  : self.get_operation_mode (),
                     "duration_sec"  : taken,
                     "result" :  "FAILURE",
                     "stdout" : err_msg,
         };
         #pprint(elk_obj['test']);
         elk.reg.push_data(elk_obj)
    def addFailure(self, test, err, capt=None, tb_info=None):
        """Add failure output to Xunit report.
        """
        taken = self._timeTaken()
        tb = format_exception(err, self.encoding)
        self.stats['failures'] += 1
        id = test.id()

        self.errorlist.append(
            u'<testcase classname=%(cls)s name=%(name)s time="%(taken).3f">'
            u'<failure type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]>'
            u'</failure>%(systemout)s%(systemerr)s</testcase>' %
            {'cls': self._quoteattr(id_split(id)[0]),
             'name': self._quoteattr(id_split(id)[-1]),
             'taken': taken,
             'errtype': self._quoteattr(nice_classname(err[0])),
             'message': self._quoteattr(exc_message(err)),
             'tb': escape_cdata(tb),
             'systemout': self._getCapturedStdout(),
             'systemerr': self._getCapturedStderr(),
             })
Beispiel #14
0
    def addFailure(self, test, err, capt=None, tb_info=None):
        """Add failure output to Xunit report.
        """
        taken = self._timeTaken()
        tb = format_exception(err, self.encoding)
        self.stats['failures'] += 1
        _id = test.id()

        self.errorlist.append({
            'failed': True,
            'class': id_split(_id)[0],
            'name': id_split(_id)[-1],
            'time': str(datetime.timedelta(seconds=taken)),
            'type': 'failures',
            'exception': nice_classname(err[0]),
            'message': exc_message(err),
            'tb': '',  # do not display traceback on failure
            'stdout': self._getCapturedStdout(),
            'stderr': self._getCapturedStderr(),
            'shortDescription': test.shortDescription(),
        })