예제 #1
0
 def test_animals_abs_and_inheritance(self):
     self.assertEqual(Animal.__bases__[0].__name__, "ABC")
     self.assertTrue(len(list(Animal.__abstractmethods__)) > 0)
     self.assertTrue("Animal" in [x.__name__ for x in Bird.__bases__])
     self.assertTrue("ABC" in [x.__name__ for x in Bird.mro()])
     self.assertTrue("Animal" in [x.__name__ for x in Mammal.__bases__])
     self.assertTrue("ABC" in [x.__name__ for x in Mammal.mro()])
     self.assertEqual(Mouse.__bases__[0].__name__, "Mammal")
     self.assertEqual(Dog.__bases__[0].__name__, "Mammal")
     self.assertEqual(Tiger.__bases__[0].__name__, "Mammal")
     self.assertEqual(Cat.__bases__[0].__name__, "Mammal")
     self.assertEqual(Owl.__bases__[0].__name__, "Bird")
     self.assertEqual(Hen.__bases__[0].__name__, "Bird")
예제 #2
0
 def __init__(self, name, weight, living_region):
     Mammal.__init__(self, name, weight, living_region)
예제 #3
0
 def __init__(self, name, weight, living_region, food_eaten=0):
     Mammal.__init__(self, name, weight, living_region, food_eaten)