我有一堂课:
class MyClass(object):
@property
def myproperty(self):
return 'hello'
使用mox
and py.test
,我如何模拟出来myproperty
?
我试过了:
mock.StubOutWithMock(myclass, 'myproperty')
myclass.myproperty = 'goodbye'
和
mock.StubOutWithMock(myclass, 'myproperty')
myclass.myproperty.AndReturns('goodbye')
但两者都失败了AttributeError: can't set attribute
。