I have the following python program that uses mocking.
#!/usr/bin/env python
import mock
def my_func1():
return "Hello"
my_func = mock.MagicMock()
my_func.return_value = "Goodbye"
print my_func()
print my_func()
Output:
Goodbye
Goodbye
All is working as it should. Great.
But I want the mocked out method to return Goodbye
the first time it is called and raise an exception the second time it is called. How can I do that??