[英]I have a python file with multiple exception for each block , I need to utest for the same . Is there any approach to cover all exceptions at one go?
要為其編寫 utest 的示例 python 文件:
try:
code
except Exception as e:
print
try:
code
except Exception as e:
print
try:
code
except Exception as e:
print
try:
code
except Exception as e:
print
try:
code
except Exception as e:
print
try:
code
except Exception as e:
print
try:
code
except Exception as e:
print
我想你正在尋找這個:
try:
foo()
except (SomeException, OtherException, AnotherException) as exp:
...
https://docs.python.org/3/tutorial/errors.html#handling-exceptions
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.