def test_replace_fail_replacee_non_member(self, make_mock_microclassifier): population = Population(max_micros=1) replacee = make_mock_microclassifier() replacer = make_mock_microclassifier() population.insert(replacer) with pytest.raises(MemberNotFoundError): population.replace(replacee, replacer)
def test_replace_succeed_both_micros(self, make_mock_microclassifier): population = Population(max_micros=2) replacee = make_mock_microclassifier() replacer = make_mock_microclassifier() population.insert(replacee) population.insert(replacer) assert population.num_micros == 2 assert population.num_macros == 2 population.replace(replacee, replacer) assert population.num_micros == 2 assert population.num_macros == 1
def test_replace_succeed_replacer_is_macro(self, make_mock_microclassifier, make_mock_macroclassifier): population = Population(max_micros=3) replacee = make_mock_microclassifier() replacer = make_mock_macroclassifier(numerosity=2) population.insert(replacee) population.insert(replacer) assert population.num_micros == 3 assert population.num_macros == 2 population.replace(replacee, replacer) assert population.num_micros == 3 assert population.num_macros == 1