def test_true_when_prob__of_killing_is_one(self, teardown_carnivore_tests, example_properties): """ Asserts that kill method returns True when prob_kill is one. """ herbivore = Herbivore(example_properties) carnivore = Carnivore(example_properties) herbivore.find_fitness() carnivore.find_fitness() carnivore.params["DeltaPhiMax"] = 0.1 assert carnivore.kill(herbivore) is True
def test_correct_prob_of_killing(self, example_properties, teardown_carnivore_tests): """ Asserts that prob_kill returns correct probability. """ herb_fitness = 0.5 carnivore = Carnivore(example_properties) carnivore.params["DeltaPhiMax"] = 10.0 carnivore.find_fitness() prob = carnivore.prob_kill(herb_fitness) assert prob == approx(0.04983411986)
def test_list_of_herbs_returned(self, example_properties, teardown_carnivore_tests): """ Asserts that eat method returns a list of herbivore class instances when the carnivore has eaten a herbivore. """ carnivore = Carnivore(example_properties) carnivore.find_fitness() carnivore.params["DeltaPhiMax"] = 0.1 herb = Herbivore(example_properties) herb.find_fitness() eaten_herbs = carnivore.attempt_eating_all_herbivores_in_cell([herb]) assert type(eaten_herbs) is list
def test_carn_gained_weight_after_eating(self, example_properties, teardown_carnivore_tests): """ Assert that carnivore has gained weight after eat method when there is a weaker herbivore available. """ carnivore = Carnivore(example_properties) carnivore.find_fitness() old_weight = carnivore.weight carnivore.params["DeltaPhiMax"] = 0.1 herb = Herbivore(example_properties) herb.find_fitness() carnivore.attempt_eating_all_herbivores_in_cell([herb]) assert old_weight < carnivore.weight