python class 属性 上的单元测试

Unit testing on a python class property

假设我有一个 class:

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')