0
A
回答
4
该采取截图:
try:
assert something == something_else
except AssertionError:
take_screenshot()
是你可以做的一种方式。
在某些情况下,你可能想使用一个装饰:
>>> def assertd(function):
def _f(*args):
try:
return function(*args)
except AssertionError:
takescreenshot()
return _f
>>> @assertd
def f(x, y):
assert x > 0
return x + y
>>> f(1, 2)
3
>>> f(5, 6)
11
>>> f(-7, 8)
<Screenshot taken>
相关问题
- 1. 断言失败时触发函数
- 2. AfxGetInstanceHandle()触发断言失败
- 3. “断言失败”在析构函数
- 4. 递归函数失败断言
- 5. ld:断言失败:(src.atom!= NULL),函数addRelocFixup
- 6. CreateWindowsEx()失败,触发断点
- 7. 断言失败
- 8. 断言失败
- 9. 断言失败 - [NSLayoutConstraint常数]
- 10. 为什么失败的断言触发承诺?
- 11. JMeter断言失败
- 12. xcode断言失败
- 13. calcopticalflowpyrlk断言失败
- 14. MZFormSheetController断言失败
- 15. UICollectionView断言失败
- 16. OpenCv断言失败
- 17. findcontours断言失败
- 18. 断言失败时CPPUNIT_ASSERT_MESSAGE在析构函数中崩溃
- 19. 断言调试器断言失败
- 20. 如何停止在Visual Studio中的第一个断言失败?
- 21. MenuItem位图引发断言失败...
- 22. 的UITableView CoreData断言失败
- 23. 断言失败:: malloc的
- 24. 断言失败 - [UITableView的_endCellAnimationsWithContext]
- 25. Python的os.isfile断言失败
- 26. OpenCV的nMatToBitmap断言失败
- 27. PyGTK的“断言失败GTK_IS_WINDOW
- 28. C:malloc的断言失败
- 29. JProfiler的断言失败
- 30. OpenCV:Traincascade失败“断言失败_img.cols == winSize.width”
感谢应该做我需要 – Calum
@Calum没问题!如果这个答案对你有帮助,那么在某些时候[接受](http://stackoverflow.com/help/accepted-answer)会很好。 – rlms