def test_extended_classes_of_inheriting_stereotypes__remove_superclass_stereotype( self): m1 = CMetaclass() s1 = CStereotype(extended=[m1]) s2 = CStereotype(superclasses=[s1], extended=[m1]) m1.stereotypes = s2 eq_(set(s1.extended), set()) eq_(set(s2.extended), {m1}) eq_(set(m1.stereotypes), {s2})
def test_extended_classes_of_inheriting_stereotypes__superclass_is_set_to_the_same( self): m1 = CMetaclass("M1") s1 = CStereotype("S1") s2 = CStereotype("S2", extended=[m1], superclasses=[s1]) m1.stereotypes = [s2, s1] eq_(set(s1.extended), {m1}) eq_(set(s2.extended), {m1}) eq_(set(m1.stereotypes), {s2, s1})
def test_extended_classes_of_inheriting_stereotypes__superclass_has_none( self): m1 = CMetaclass() m2 = CMetaclass(superclasses=[m1]) s1 = CStereotype() s2 = CStereotype(superclasses=[s1]) m2.stereotypes = s2 eq_(len(s1.extended), 0) eq_(set(m2.stereotypes), {s2})
def test_extended_classes_of_inheriting_stereotypes__superclass_is_set_to_metaclasses_superclass_indirectly( self): m1 = CMetaclass() m2 = CMetaclass(superclasses=[m1]) m3 = CMetaclass(superclasses=[m2]) s1 = CStereotype() s2 = CStereotype(superclasses=[s1], extended=[m3]) m1.stereotypes = s1 eq_(set(s1.extended), {m1}) eq_(set(s2.extended), {m3}) eq_(set(m1.stereotypes), {s1}) eq_(set(m3.stereotypes), {s2})
def test_stereotype_extension_add_remove(self): s1 = CStereotype("S1") eq_(set(s1.extended), set()) mcl1 = CMetaclass(stereotypes=[s1]) eq_(set(s1.extended), {mcl1}) eq_(set(mcl1.stereotypes), {s1}) mcl2 = CMetaclass(stereotypes=s1) eq_(set(s1.extended), {mcl1, mcl2}) eq_(set(mcl1.stereotypes), {s1}) eq_(set(mcl2.stereotypes), {s1}) s1.extended = [mcl2] eq_(set(s1.extended), {mcl2}) eq_(set(mcl1.stereotypes), set()) eq_(set(mcl2.stereotypes), {s1}) s2 = CStereotype("S2", extended=[mcl2]) eq_(set(mcl2.stereotypes), {s2, s1}) eq_(set(s1.extended), {mcl2}) eq_(set(s2.extended), {mcl2}) mcl2.stereotypes = [] eq_(set(mcl2.stereotypes), set()) eq_(set(s1.extended), set()) eq_(set(s2.extended), set())