def test_for_classifier_in_diamond_generalization(self): leaf = Classifier('Leaf') middle1 = Classifier('Middle1', generals=[leaf]) middle2 = Classifier('Middle2', generals=[leaf]) top = Classifier('Top', generals=[middle1, middle2]) assert_that(list(all_indirect_generals(top)), equal_to([middle1, middle2, leaf]))
def test_for_classifier_with_three_generals(self): base1 = Classifier('Base') base2 = Classifier('Base') base3 = Classifier('Base') derived = Classifier('Derived', generals=[base1, base2, base3]) assert_that(list(all_indirect_generals(derived)), equal_to([base1, base2, base3]))
def test_for_classifier_in_generalization_tree(self): leaf1 = Classifier('Leaf1') leaf2 = Classifier('Leaf2') leaf3 = Classifier('Leaf3') leaf4 = Classifier('Leaf4') middle1 = Classifier('Middle1', generals=[leaf1, leaf2]) middle2 = Classifier('Middle2', generals=[leaf3, leaf4]) top = Classifier('Top', generals=[middle1, middle2]) assert_that(list(all_indirect_generals(top)), equal_to([middle1, middle2, leaf1, leaf2, leaf3, leaf4]))
def test_for_classifier_in_generalization_chain(self): first = Classifier('First') second = Classifier('Second', generals=[first]) third = Classifier('Third', generals=[second]) assert_that(list(all_indirect_generals(third)), equal_to([second, first]))
def test_for_classifier_with_one_general(self): base = Classifier('Base') derived = Classifier('Derived', generals=[base]) assert_that(list(all_indirect_generals(derived)), equal_to([base]))
def test_for_classifier_without_generals(self): assert_that(list(all_indirect_generals(Classifier('A'))), empty())