コード例 #1
0
 def test_true_if_birth_prob_one(self, example_properties_w_40):
     """
     Tests the will_birth_take_place method by checking if True is returned
     when the probability of giving birth is 1.
     """
     animal = Animal(example_properties_w_40)
     animal.find_fitness()
     assert animal.will_birth_take_place(num_animals=6) is True
コード例 #2
0
 def test_false_if_rand_num_more_than_birth_prob(self, mocker):
     """
     Tests will_birth_take_place method by checking if False is returned
     when a random number larger than a specific probability is drawn.
     """
     test_properties_prob = {"species": "animal", "age": 63, "weight": 30}
     mocker.patch('numpy.random.random', return_value=0.95)
     animal = Animal(test_properties_prob)
     animal.find_fitness()
     assert animal.will_birth_take_place(num_animals=6) is not True
コード例 #3
0
 def test_true_if_rand_num_less_than_birth_prob(self, mocker):
     """
     Tests will_birth_take_place method. Checks if True is returned when
     random number less than a specific probability is drawn.
     """
     test_properties_num_less = {
         "species": "animal",
         "age": 63,
         "weight": 30
     }
     mocker.patch('numpy.random.random', return_value=0.8)
     animal = Animal(test_properties_num_less)
     animal.find_fitness()
     assert animal.will_birth_take_place(num_animals=6) is True