def test_zoo_5_animals(): for animal in 'dog cat fish lion mouse'.split(): Animal(animal) zoo = Animal.zoo() expected = ("10001. Dog", "10002. Cat", "10003. Fish", "10004. Lion", "10005. Mouse") assert zoo == '\n'.join(expected)
def test_zoo_5_animals(): for animal in 'dog cat fish lion mouse'.split(): Animal(animal) zoo = Animal.zoo() assert "10001. Dog" in zoo assert "10002. Cat" in zoo assert "10003. Fish" in zoo assert "10004. Lion" in zoo assert "10005. Mouse" in zoo
def test_animal_instance_str(): horse = Animal('horse') assert str(horse) == "10006. Horse" horse = Animal('monkey') assert str(horse) == "10007. Monkey"
import sys sys.path.append('../../lib/') from zoo import Animal a = Animal("zoo") print(a.get_name())
def getAnimal(): animal = Animal("name") return animal
def test_Animal(self): with pytest.raises(TypeError) as excinfo: animal = Animal('Mammal', 1, 'Black') exception_message = excinfo.value.args[0] assert exception_message == "Can't instantiate abstract class Animal with abstract methods __init__, sound"