Ejemplo n.º 1
0
def test_animal_1():
    """
        fonction pour tester Animal
    """
    mon_animal = Animal("zarafa")
    print("TO_STRING: " + mon_animal.to_string())
    mon_animal.set_attack_point(5)
    print("TO_STRING: " + mon_animal.to_string())
    mon_animal.set_life_point(100)
    print("TO_STRING: " + mon_animal.to_string())
    mon_animal.set_voice("ba3aaaaw")
    print("TO_STRING: " + mon_animal.to_string())
    mon_animal.eat()
    print("TO_STRING: " + mon_animal.to_string())
    mon_animal.eat(20)
    print("TO_STRING: " + mon_animal.to_string())
    mon_animal_2 = Animal("7allouf")
    print("TO_STRING: " + mon_animal_2.to_string())
    mon_animal_2.set_life_point(200)
    mon_animal_2.set_attack_point(30)
    print("TO_STRING: " + mon_animal_2.to_string())
    mon_animal_2.set_voice("Grrrrrrrr")
    print("TO_STRING: " + mon_animal_2.to_string())
    mon_animal_2.eat(40)
    print("TO_STRING: " + mon_animal_2.to_string())
    mon_animal_2.attack(mon_animal)
    print("TO_STRING: " + mon_animal_2.to_string())
    print("TO_STRING: " + mon_animal.to_string())
    print("Execution de str():")
    print(str(mon_animal))
    print("print(mon_animal):")
    print(mon_animal)
Ejemplo n.º 2
0
def test_attack():
    """
        Test de la fonction attack
    """
    test_attacking = Animal("Test", 5, 2, "KILL")
    test_victim = Animal("Test2", 10, 1, "HELP")
    test_attacking.attack(test_victim)
    assert test_victim.get_life_point() == 8