我有一个类
class ActivationResult(object):
def __init__(self, successful : bool):
self._successful = successful
def getSuccessful(self) -> bool:
return self._successful
并进行测试
def testSuccessfulFromCreate(self):
target = ActivationResult(True)
self.assertEquals(target._successful, True)
self.assertEquals(target.getSuccessful, True)
第一个断言很好,但第二个失败并显示错误信息:
AssertionError: <bound method ActivationResult.getSuccess[84 chars]EB8>> != True
。当我尝试打印时同样会出现这个问题。为什么会这样?
@property
。 - jonrsharpe