我在捕获unitest代码中的异常时遇到了一个问题。 下面是我的代码
def get_param(param)
if param is None:
raise ValueError('param is not set')
def test_param():
with pytest.raises(ValueError) as e:
get_param()
问题是,当函数没有引发异常时,test_param()会失败,并出现以下错误。你知道吗
Failed: DID NOT RAISE <class 'ValueError'>
当get_param(param)函数抛出异常时,它可以正常工作。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐