当前位置: 首页>>代码示例>>Python>>正文


Python Person.parents方法代码示例

本文整理汇总了Python中models.Person.parents方法的典型用法代码示例。如果您正苦于以下问题:Python Person.parents方法的具体用法?Python Person.parents怎么用?Python Person.parents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Person的用法示例。


在下文中一共展示了Person.parents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PersonTest

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import parents [as 别名]

#.........这里部分代码省略.........
        self.other_son.born_in = self.d
        self.other_son.family = self.ff
        self.other_son.save()

    def test_family_leader_patriarchal(self):
        """
        Must return the correct family leader based patriarchal configured
        leadership.
        """
        self.son.family = self.ff
        self.assertEqual(self.son.family_leader(), self.father)

    def test_family_leader_matriarchal(self):
        """
        Must return the correct family leader based matriarchal configured
        leadership.
        """
        self.son.family = self.mf
        self.assertEqual(self.son.family_leader(), self.mother)

    def test_family_leader_not_defined(self):
        """
        Must return a None object when the leadership is not defined.
        """
        self.son.family = self.mf
        self.son.family.leadership = None
        self.assertIsNone(self.son.family_leader())

    def test_is_alive_not_defined(self):
        """
        Tests the return value when a Person hasn't defined a born date nor a
        deceased date.
        """
        self.son.born_in = None
        self.assertIsNone(self.son.is_alive())

    def test_is_alive_not_alive(self):
        """
        Tests the return value when a Person is dead, based on the object
        dates.
        """
        self.son.born_in = self.d
        self.son.deceased_in = self.d
        self.assertFalse(self.son.is_alive())

    def test_is_alive_alive(self):
        """
        Tests the return value when a Person is dead, based on the object
        dates.
        """
        self.son.born_in = self.d
        self.assertTrue(self.son.is_alive())

    def test_brothers(self):
        """
        Tests the ``brothers()`` method to validate that returns other
        :model:`family.Person` instances related by parents, but not the
        current object.
        """
        self.assertTrue(self not in self.son.brothers())

    def test_parents(self):
        """
        Tests the ``parents()`` method to validate that returns other
        :model:`family.Person` instances related to the current one as parents.
        """
        parents = self.son.parents()
        self.assertEqual(2, len(parents))
        self.assertTrue(self.son.father in parents)
        self.assertTrue(self.son.mother in parents)

    def test_descendence_invalid(self):
        """
        Tests the ``descendence()`` method to validate that raises an exception
        if current instance has not sex value defined.
        """
        self.father.sex = None
        self.assertRaises(ValueError, self.father.descendence)

    def test_father_descendence(self):
        """
        Tests the ``descendence()`` method to validate that returns other
        :model:`family.Person` instances related to the current one as
        father's descendence.
        """
        d = self.father.descendence()
        self.assertEqual(2, len(d))
        self.assertTrue(self.son in d)
        self.assertTrue(self.other_son in d)

    def test_mother_descendence(self):
        """
        Tests the ``descendence()`` method to validate that returns other
        :model:`family.Person` instances related to the current one as
        mother's descendence.
        """
        d = self.mother.descendence()
        self.assertEqual(2, len(d))
        self.assertTrue(self.son in d)
        self.assertTrue(self.other_son in d)
开发者ID:ariel17,项目名称:fquest,代码行数:104,代码来源:tests.py


注:本文中的models.Person.parents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。