当前位置: 首页>>代码示例>>Python>>正文


Python Failure.cleanFailure方法代码示例

本文整理汇总了Python中twisted.python.failure.Failure.cleanFailure方法的典型用法代码示例。如果您正苦于以下问题:Python Failure.cleanFailure方法的具体用法?Python Failure.cleanFailure怎么用?Python Failure.cleanFailure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.python.failure.Failure的用法示例。


在下文中一共展示了Failure.cleanFailure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tracebackFromCleanFailure

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import cleanFailure [as 别名]
 def test_tracebackFromCleanFailure(self):
     """
     Errors added through the L{PyUnitResultAdapter} have the same
     traceback information as if there were no adapter at all, even
     if the Failure that held the information has been cleaned.
     """
     try:
         1 / 0
     except ZeroDivisionError:
         exc_info = sys.exc_info()
         f = Failure()
     f.cleanFailure()
     pyresult = pyunit.TestResult()
     result = PyUnitResultAdapter(pyresult)
     result.addError(self, f)
     self.assertEqual(pyresult.errors[0][1], "".join(traceback.format_exception(*exc_info)))
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:18,代码来源:test_pyunitcompat.py

示例2: test_cleanedFailure

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import cleanFailure [as 别名]
 def test_cleanedFailure(self):
     """
     A cleaned Failure object has a fake traceback object; make sure that
     logging such a failure still results in the exception details being
     logged.
     """
     def failing_func():
         1 / 0
     try:
         failing_func()
     except ZeroDivisionError:
         failure = Failure()
     failure.cleanFailure()
     event = dict(log_format='Hi mom', who='me', log_failure=failure)
     records, output = self.logEvent(event)
     self.assertEqual(len(records), 1)
     self.assertIn(u'Hi mom', output)
     self.assertIn(u'in failing_func', output)
     self.assertIn(u'ZeroDivisionError', output)
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:21,代码来源:test_stdlib.py


注:本文中的twisted.python.failure.Failure.cleanFailure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。