I have the following function which is called twice
def func():
i=2
while i
call_me("abc")
i-=1
I need to test this function whether it is called twice. Below test case test's if it called at all/many times with given arguments.
@patch('call_me')
def test_func(self,mock_call_me):
self.val="abc"
self.assertEqual(func(),None)
mock_call_me.assert_called_with(self.val)
I want to write a test case where "mock_call_me.assert_called_once_with("abc")" raises an assertion error so that i can show it is called twice.
I don't know whether it is possible or not.Can anyone tell me how to do this?
Thanks