Ejemplo n.º 1
0
 def test_death(self, mocker):
     h = Herb()
     c = Carn()
     h.fitness = 0
     c.fitness = 0
     assert h.death() is True
     assert c.death() is True
     h = Herb()
     c = Carn()
     mocker.patch('random.uniform', return_value=1)
     assert h.death() is False
     assert c.death() is False
     h = Herb()
     c = Carn()
     mocker.patch('random.uniform', return_value=0)
     assert h.death() is True
     assert c.death() is True
Ejemplo n.º 2
0
 def test_death(self, mocker):
     """Tests that the death method works correctly.
     The fitness of herbivores and carnivores are set as needed to have the
     correct return object from the death method.
     The mocker is used to give spesific values from random functions used
     in the module.
     """
     h = Herb()
     c = Carn()
     h.fitness = 0
     c.fitness = 0
     assert h.death() is True
     assert c.death() is True
     h = Herb()
     c = Carn()
     mocker.patch("random.uniform", return_value=1)
     assert h.death() is False
     assert c.death() is False
     h = Herb()
     c = Carn()
     mocker.patch("random.uniform", return_value=0)
     assert h.death() is True
     assert c.death() is True