コード例 #1
0
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)
コード例 #2
0
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
コード例 #3
0
def test_animal_instance_str():
    horse = Animal('horse')
    assert str(horse) == "10006. Horse"
    horse = Animal('monkey')
    assert str(horse) == "10007. Monkey"
コード例 #4
0
import sys
sys.path.append('../../lib/')
from zoo import Animal

a = Animal("zoo")
print(a.get_name())
コード例 #5
0
ファイル: test_zoo.py プロジェクト: Uyutaka/zooWithPytest
def getAnimal():
    animal = Animal("name")
    return animal
コード例 #6
0
 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"