コード例 #1
0
    def test_procreation(self, mocker):
        herb = Herbivore(4, 30)
        herb_born = herb.procreation(1)
        assert herb_born is None

        carn = Carnivore(4, 30)
        carn_born = carn.procreation(1)
        assert carn_born is None

        herb = Herbivore(4, 30)
        weight = herb.weight
        lose_weight = (
            herb.params_dict["zeta"] *
            (herb.params_dict["w_birth"] + herb.params_dict["sigma_birth"]))
        assert weight < lose_weight
        for _ in range(10):
            procreation = herb.procreation(10)
            assert procreation is None

        herb = Herbivore(5, 40)
        phi = herb.phi
        mocker.patch('random.random', return_value=0.0001)
        herb.procreation(2)
        mocker.patch('random.gauss', return_value=5)
        herb.weight = 40 - (herb.params_dict["xi"] *
                            herb.get_initial_weight_offspring())
        phi_procreated = herb.phi
        assert herb.weight == 34  # NOT WORKING CHECK IT OUT!!!!
        assert phi > phi_procreated
コード例 #2
0
    def test_get_initial_weight(self, mocker):
        mocker.patch('random.gauss', return_value=5)

        herb = Herbivore(3, None)
        assert herb.get_initial_weight_offspring() == 5

        carn = Carnivore(2, None)
        assert carn.get_initial_weight_offspring() == 5