コード例 #1
0
 def test_false_when_prob_of_killing_is_zero(self, example_properties):
     """
     Asserts that kill method returns False when prob_kill is zero.
     """
     herbivore = Herbivore(example_properties)
     carnivore = Carnivore(example_properties)
     herbivore.find_fitness()
     carnivore.fitness = 0.5
     assert carnivore.kill(herbivore) is False
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
 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