更新时间:2022-02-17 03:32:44
pytest捕获ExceptionInfo
对象中的异常.您可以在例外之后比较确切的类型.
pytest captures the exception in an ExceptionInfo
object. You can compare the exact type after the exception.
def test_get_holidays_raises_ioerror():
requests.get.side_effect = IOError
with pytest.raises(IOError) as excinfo:
get_holidays()
assert type(excinfo.value) is IOError