コード例 #1
0
def test_birth_weight_loss():
    """Does birthing an animal reduce the animals weight to a non-negative number?"""
    h1 = Herbivore(weight=20)
    h2 = Herbivore()
    h1.change_weight(h2.weight, True)
    assert h1.weight < 20
    assert h1.weight > 0
コード例 #2
0
def test_natural_weight_loss():
    """Does animals lose weight each year as expected?"""
    h = Herbivore()
    weight_h = h.weight
    h.change_weight()
    assert weight_h - (h._ani_params['eta'] * weight_h) == h.weight

    c = Carnivore()
    weight_c = c.weight
    c.change_weight()
    assert weight_c - (c._ani_params['eta'] * weight_c) == c.weight
コード例 #3
0
def test_herbivore_eating_weight_change():
    """Does herbivores gain weight correctly?"""
    h1 = Herbivore()
    weight = h1.weight + 10 * h1._ani_params['beta']
    h1.change_weight(10)
    assert weight == h1.weight