How do I mock a class property with mox?
- by Harley
I have a class:
class myclass(object):
@property
def myproperty(self):
return 'hello'
Using mox and py.test, how do I mock out myproperty?
I've tried:
mock.StubOutWithMock(myclass, 'myproperty')
myclass.myproperty = 'goodbye'
and
mock.StubOutWithMock(myclass, 'myproperty')
myclass.myproperty.AndReturns('goodbye')
but both fail with AttributeError: can't set attribute.