Is it possible to have a side_effect on a property? If I look at the Mock documentation it seems it’s only possible on object methods.
I am trying to test the following:
def get_object(self):
try:
return self.request.user.shop
except Shop.DoesNotExist:
return None
I want Shop to raise a DoesNotExist exception.
Guess maybe I wasn’t clear enough but I am talking about the voidspace mock library.
The author made a blog post about this problem. I went for the first solution which looks like this:
http://www.voidspace.org.uk/python/weblog/arch_d7_2010_11_20.shtml#e1196