Beispiel #1
0
 def test_can_instatiate_birds():
     owl = Owl("Pip", 10, 10)
     print(owl)
     meat = Meat(4)
     print(owl.make_sound())
     owl.feed(meat)
     veg = Vegetable(1)
     print(owl.feed(veg))
     print(owl)
     hen = Hen("Harry", 10, 10)
     veg = Vegetable(3)
     fruit = Fruit(5)
     meat = Meat(1)
     print(hen)
     print(hen.make_sound())
     hen.feed(veg)
     hen.feed(fruit)
     hen.feed(meat)
     print(hen)
Beispiel #2
0
def test_feeding_birds_should_increase_weight():
    test = namedtuple('test', 'bird food expected_increase')
    tests = [
        test(Owl('buho', weight=3, wing_size=30),
             food=Meat(3),
             expected_increase=3 * 0.25),
        test(Hen('hencho', weight=2, wing_size=10),
             food=Seed(3),
             expected_increase=3 * 0.35)
    ]

    for bird, food, expected_increase in tests:
        before = bird.weight
        bird.feed(food)
        after = bird.weight

        assert after - before == expected_increase, \
            f'{bird.__class__.__name__} with w:{before} ate {food.quantity} {food.__class__.__name__}'\
            f' should have gained {expected_increase}, but it gained {after - before}'
print(miki)
gosheto = Dog("goshe", 20, "gruzia")
print(gosheto)
print(gosheto.feed(kartof))
gosheto.feed(meso)
print(gosheto)

owl = Owl("Pip", 10, 10)
print(owl)
meat = Meat(4)
print(owl.make_sound())
owl.feed(meat)
veg = Vegetable(1)
print(owl.feed(veg))
print(owl)
hen = Hen("Harry", 10, 10)
veg = Vegetable(3)
fruit = Fruit(5)
meat = Meat(1)
print(hen)
print(hen.make_sound())
hen.feed(veg)
hen.feed(fruit)
hen.feed(meat)
print(hen)


class WildFarmTests(unittest.TestCase):
    def test_first_zero(self):
        owl = Owl("Pip", 10, 10)
        self.assertEqual(str(owl), "Owl [Pip, 10, 10, 0]")
Beispiel #4
0
def test_bird_sounds():
    tests = [(Owl('buho', weight=3, wing_size=30), 'Hoot Hoot'),
             (Hen('hencho', weight=2, wing_size=10), 'Cluck')]
    for bird, expected_sound in tests:
        assert bird.make_sound() == expected_sound, \
            f'({bird.__class__.__name__}) should "{expected_sound}" was "{bird.make_sound()}"'
Beispiel #5
0
    def test_can_initiate_bird():
        Owl("Buho", weight=2, wing_size=20)
        Hen("Hencho", weight=3, wing_size=30)

        print("test_can_initiate_bird passed")
Beispiel #6
0
from project.food import Vegetable, Fruit, Meat, Seed
from project.animals.birds import Hen, Owl
from project.animals.mammals import Mouse, Cat, Dog, Tiger

hen = Hen("Heny", 2, 25)
owl = Owl("Owly", 2.25, 27)
mouse = Mouse("Mousy", 0.6, "basement")
cat = Cat("Catsy", 3.5, "house")
dog = Dog("Doggo", 5, "yard")
tiger = Tiger("Tigeria", 7, "woods")

# print(hen)
# print(owl)
# print(mouse)
# print(cat)
# print(dog)
# print(tiger)
#
# print(hen.make_sound())
# print(owl.make_sound())
# print(mouse.make_sound())
# print(cat.make_sound())
# print(dog.make_sound())
# print(tiger.make_sound())
#
veg = Vegetable(5)
meat = Meat(3)
fruit = Fruit(6)
seed = Seed(10)
#
# print(owl.feed(fruit))