假设我有一堂课:
class Player(object):
def __init__(self):
self.goal = ''
@property
def goal(self):
return self.goal
goal
鉴于该属性不可调用,是否可以在该属性上编写单元测试?
怎么样:
def test_goal_property(self):
dummy_player = Player()
self.assertEqual(dummy_player.goal, '')
要么
def test_goal_property(self):
dummy_player = Player()
dummy_player.goal = 'something'
self.assertEqual(dummy_player.goal, 'something')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句