Beispiel #1
0
    def test_death_occurs_if_fitness_is_0(self):
        """Test to show that animal will die if fitness is 0
        """
        loc = (2, 7)
        i = Island()
        h_sim = Herbivore(i, loc, weight=0)
        c_sim = Carnivore(i, loc, weight=0)

        assert h_sim.death()
        assert c_sim.death()
Beispiel #2
0
    def test_death_does_not_occur_if_prob_is_0(self, mocker):
        """Test to show that death will not occur if we mock the probability to
        highest return value
        """
        mocker.patch('random.random', return_value=1)
        loc = (2, 7)
        i_sim = Island()
        h_sim = Herbivore(i_sim, loc)
        c_sim = Carnivore(i_sim, loc)

        assert not h_sim.death()
        assert not c_sim.death()
Beispiel #3
0
    def test_death_occurs_if_prob_is_1(self, mocker):
        """Test to show that death will occur if we mock the probability to
        lowest return value
        """
        mocker.patch('random.random', return_value=0)
        loc = (2, 7)
        i_sim = Island()
        h_sim = Herbivore(i_sim, loc)
        c_sim = Carnivore(i_sim, loc)

        assert h_sim.death()
        assert c_sim.death()