side_effect allows you to perform side effects, including raising an exception when a mock is called: >>> >>> mock = Mock(side_effect=KeyError('foo')) > ...
確定! 回上一頁