本文整理汇总了Python中animal.Animal.get_info方法的典型用法代码示例。如果您正苦于以下问题:Python Animal.get_info方法的具体用法?Python Animal.get_info怎么用?Python Animal.get_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类animal.Animal
的用法示例。
在下文中一共展示了Animal.get_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestZoo
# 需要导入模块: from animal import Animal [as 别名]
# 或者: from animal.Animal import get_info [as 别名]
class TestZoo(unittest.TestCase):
def setUp(self):
self.bear = Animal("bear", 12, "Pesho", "male", 60)
self.panda = Animal("panda", 12, "Ivo", "male", 60)
animals = [self.bear, self.panda]
self.zoo = Zoo(animals, 10, 200)
def test_init(self):
self.assertEqual(self.zoo.animals, [self.bear, self.panda])
self.assertEqual(self.zoo.budget, 200)
self.assertEqual(self.zoo.capacity, 10)
def test_get_info(self):
self.assertEqual(self.bear.get_info("gestation_period"), 3)
def test_move_to_habitat(self):
self.zoo.move_to_habitat("bear", "Pesho")
self.assertEqual(self.zoo.animals, [self.panda])
def test_daily_incomes(self):
self.assertEqual(self.zoo.get_daily_incomes(), 120)
def test_accommodate_an_animal(self):
bear2 = Animal("bear", 12, "Pesho2", "male", 60)
self.zoo.accommodate_an_animal(bear2)
self.assertEqual(self.zoo.animals, [self.bear, self.panda, bear2])
def test_remove_dead_animals(self):
bear2 = Animal("bear", 12, "Pesho2", "male", 60)
self.zoo.accommodate_an_animal(bear2)
bear2.is_alive = False
self.zoo.remove_dead_animals()
self.assertEqual(self.zoo.animals, [self.bear, self.panda])