當前位置: 首頁>>代碼示例>>Python>>正文


Python Report.failed方法代碼示例

本文整理匯總了Python中kitty.data.report.Report.failed方法的典型用法代碼示例。如果您正苦於以下問題:Python Report.failed方法的具體用法?Python Report.failed怎麽用?Python Report.failed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kitty.data.report.Report的用法示例。


在下文中一共展示了Report.failed方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testFailureInSubReportEntry

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
 def testFailureInSubReportEntry(self):
     entry_name = 'sub report'
     report = Report(self.report_name)
     subreport = Report(entry_name)
     report.add(entry_name, subreport)
     subreport.failed(self.failure_reason)
     self.assertEqual(report.get_status(), Report.FAILED)
     self.assertEqual(report.get('reason'), self.failure_reason)
開發者ID:cisco-sas,項目名稱:kitty,代碼行數:10,代碼來源:test_data_report.py

示例2: testSuccess

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
 def testSuccess(self):
     '''
     .. note:: success was deprecated, and it only calls passed()
     '''
     report = Report(self.report_name)
     report.failed(self.failure_reason)
     self.assertEqual(report.get_status(), Report.FAILED)
     report.success()
     self.assertEqual(report.get_status(), Report.PASSED)
開發者ID:cisco-sas,項目名稱:kitty,代碼行數:11,代碼來源:test_data_report.py

示例3: transmit

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
    def transmit(self, payload):
        '''
        Transmit single payload, and receive response, if expected.
        The actual implementation of the send/receive should be in
        ``_send_to_target`` and ``_receive_from_target``.

        :type payload: str
        :param payload: payload to send
        :rtype: str
        :return: the response (if received)
        '''
        response = None
        trans_report_name = 'transmission_0x%04x' % self.transmission_count
        trans_report = Report(trans_report_name)
        self.transmission_report = trans_report
        self.report.add(trans_report_name, trans_report)
        try:
            trans_report.add('request (hex)', payload.encode('hex'))
            trans_report.add('request (raw)', '%s' % payload)
            trans_report.add('request length', len(payload))
            trans_report.add('request time', time.time())

            request = payload.encode('hex')
            request = request if len(request) < 100 else (request[:100] + ' ...')
            self.logger.info('request(%d): %s' % (len(payload), request))
            self._send_to_target(payload)
            trans_report.success()

            if self.expect_response:
                try:
                    response = self._receive_from_target()
                    trans_report.add('response time', time.time())
                    trans_report.add('response (hex)', response.encode('hex'))
                    trans_report.add('response (raw)', '%s' % response)
                    trans_report.add('response length', len(response))
                    printed_response = response.encode('hex')
                    printed_response = printed_response if len(printed_response) < 100 else (printed_response[:100] + ' ...')
                    self.logger.info('response(%d): %s' % (len(response), printed_response))
                except Exception as ex2:
                    trans_report.failed('failed to receive response: %s' % ex2)
                    trans_report.add('traceback', traceback.format_exc())
                    self.logger.error('target.transmit - failure in receive (exception: %s)' % ex2)
                    self.logger.error(traceback.format_exc())
                    self.receive_failure = True
            else:
                response = ''
        except Exception as ex1:
            trans_report.failed('failed to send payload: %s' % ex1)
            trans_report.add('traceback', traceback.format_exc())
            self.logger.error('target.transmit - failure in send (exception: %s)' % ex1)
            self.logger.error(traceback.format_exc())
            self.send_failure = True
        self.transmission_count += 1
        return response
開發者ID:cisco-sas,項目名稱:kitty,代碼行數:56,代碼來源:server.py

示例4: testClearRestoresStatusToDefaultPassed

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
 def testClearRestoresStatusToDefaultPassed(self):
     report = Report(self.report_name)
     self.assertEqual(report.get_status(), Report.PASSED)
     report.failed('mock failure')
     report.clear()
     self.assertEqual(report.get_status(), Report.PASSED)
開發者ID:cisco-sas,項目名稱:kitty,代碼行數:8,代碼來源:test_data_report.py

示例5: testPassed

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
 def testPassed(self):
     report = Report(self.report_name)
     report.failed(self.failure_reason)
     self.assertEqual(report.get_status(), Report.FAILED)
     report.passed()
     self.assertEqual(report.get_status(), Report.PASSED)
開發者ID:cisco-sas,項目名稱:kitty,代碼行數:8,代碼來源:test_data_report.py

示例6: testFailedWithoutReason

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
 def testFailedWithoutReason(self):
     report = Report(self.report_name)
     self.assertEqual(report.get_status(), Report.PASSED)
     report.failed()
     self.assertEqual(report.get_status(), Report.FAILED)
     self.assertEqual(report.get('reason'), None)
開發者ID:cisco-sas,項目名稱:kitty,代碼行數:8,代碼來源:test_data_report.py

示例7: BaseTarget

# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import failed [as 別名]
class BaseTarget(KittyObject):
    '''
    BaseTarget contains the common logic and behaviour of all target.
    '''

    def __init__(self, name='BaseTarget', logger=None):
        super(BaseTarget, self).__init__(name, logger)
        self.controller = None
        self.monitors = []
        self.report = Report(name)
        self.test_number = None
        self.fuzzer = None

    def set_fuzzer(self, fuzzer):
        self.fuzzer = fuzzer

    def set_controller(self, controller):
        '''
        Set a controller
        '''
        self.controller = controller

    def add_monitor(self, monitor):
        '''
        Add a monitor
        '''
        self.monitors.append(monitor)

    def setup(self):
        '''
        Make sure the target is ready for fuzzing, including monitors and
        controllers
        '''
        if self.controller:
            self.controller.setup()
        for monitor in self.monitors:
            monitor.setup()

    def teardown(self):
        '''
        Clean up the target once all tests are completed
        '''
        if self.controller:
            self.controller.teardown()
        for monitor in self.monitors:
            monitor.teardown()

    def pre_test(self, test_num):
        '''
        Called when a test is started
        '''
        self.test_number = test_num
        self.report = Report(self.name)
        if self.controller:
            self.controller.pre_test(test_number=self.test_number)
        for monitor in self.monitors:
            monitor.pre_test(test_number=self.test_number)
        self.report.add('test_number', test_num)
        self.report.add('state', 'STARTED')

    def post_test(self, test_num):
        '''
        Called when test is completed, a report should be prepared now
        '''
        if self.controller:
            self.controller.post_test()
        for monitor in self.monitors:
            monitor.post_test()
        self.report.add('state', 'COMPLETED')
        if self.controller:
            controller_report = self.controller.get_report()
            self.report.add('controller', controller_report)
        for monitor in self.monitors:
            current_report = monitor.get_report()
            self.report.add(current_report.get('name'), current_report)
        if self.report.is_failed():
            self.report.failed()
        if self.report.is_failed():
            self.logger.warning('!!! Test %d failed !!!' % (test_num))

    def get_report(self):
        return self.report

    def get_session_data(self):
        '''
        Session related data dictionary to be used by data model.

        :return: dictionary (str, bytes)
        '''
        return {}
開發者ID:LucaBongiorni,項目名稱:kitty,代碼行數:92,代碼來源:base.py


注:本文中的kitty.data.report.Report.failed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。