In my python test case, I test it to catch an exception throws in my method:
self.assertRaises(Excpetion, lambda : myfunction(anObject))
Where in 'myfuction', it is expected to thru a Value Error.
def __init__( self, **kwargs ): super(Model, self).__init__(**kwargs) > self.value = kwargs['value'] E KeyError: 'value'
My question is why my test case still fails? since I am expecting it to raise 'exception'
self.assertRaises(Excpetion
https://stackoverflow.com/questions/66094739/assertraises-to-catch-exception-in-test-case February 08, 2021 at 09:07AM
没有评论:
发表评论