def test_will_birth(self, mocker): """Tests that the will_birth method works correctly. The weights of herbivores and carnivores are set as needed to have the correct return object from the will_birth method. The mocker is used to give spesific values from random functions used in the module. """ h = Herb() c = Carn() h.weight = 0 c.weight = 0 return_object_herb = h.will_birth(10) return_object_carn = c.will_birth(10) assert return_object_herb is None assert return_object_carn is None mocker.patch("random.uniform", return_value=0) h = Herb() c = Carn() h.weight = 100 c.weight = 100 return_object_herb = h.will_birth(10000) return_object_carn = c.will_birth(10000) assert isinstance(return_object_herb, Herb) assert isinstance(return_object_carn, Carn)
def test_will_birth(self, mocker): h = Herb() c = Carn() h.weight = 0 c.weight = 0 return_object_herb = h.will_birth(10) return_object_carn = c.will_birth(10) assert return_object_herb is None assert return_object_carn is None mocker.patch('random.uniform', return_value=0) h = Herb() c = Carn() h.weight = 100 c.weight = 100 return_object_herb = h.will_birth(10000) return_object_carn = c.will_birth(10000) assert isinstance(return_object_herb, Herb) assert isinstance(return_object_carn, Carn)