本文整理匯總了Python中kitty.data.report.Report.success方法的典型用法代碼示例。如果您正苦於以下問題:Python Report.success方法的具體用法?Python Report.success怎麽用?Python Report.success使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kitty.data.report.Report
的用法示例。
在下文中一共展示了Report.success方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testSuccess
# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import success [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)
示例2: transmit
# 需要導入模塊: from kitty.data.report import Report [as 別名]
# 或者: from kitty.data.report.Report import success [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