鉴于此代码:
def main(b):
try:
a = 2 / b
return "Hello World"
except Exception:
return "Exception"
如何使用修补测试处理异常的路径?
是否可以将a = 2 / b
作为修补的有效目标?
类似的问题:
How to use Python Mock to raise an exception - but with Errno set to a given value
Mocking - How do I raise exception on the caller?
Mocking a function to raise an Exception to test an except block