def test_metaclass_inheritance_double_assignment(self):
     t = CMetaclass("T")
     m1 = CMetaclass("M1")
     try:
         m1.superclasses = [t, t]
         exception_expected_()
     except CException as e:
         eq_("'T' is already a superclass of 'M1'", e.value)
     eq_(m1.name, "M1")
     eq_(t.name, "T")
     eq_(set(m1.superclasses), {t})
    def test_metaclass_superclasses_reassignment(self):
        t = CMetaclass("T")
        m1 = CMetaclass("M1", superclasses=[t])
        m2 = CMetaclass("M2", superclasses=[t])
        b1 = CMetaclass("B1", superclasses=[m1])
        b2 = CMetaclass("B2", superclasses=[m1])
        b3 = CMetaclass("B3", superclasses=[t])

        m1.superclasses = []
        b1.superclasses = []
        b2.superclasses = []

        eq_(set(t.superclasses), set())
        eq_(set(t.subclasses), {m2, b3})
        eq_(set(t.all_superclasses), set())
        eq_(set(t.all_subclasses), {m2, b3})

        eq_(set(m1.superclasses), set())
        eq_(set(m1.subclasses), set())
        eq_(set(m1.all_superclasses), set())
        eq_(set(m1.all_subclasses), set())

        eq_(set(m2.superclasses), {t})
        eq_(set(m2.subclasses), set())
        eq_(set(m2.all_superclasses), {t})
        eq_(set(m2.all_subclasses), set())

        eq_(set(b1.superclasses), set())
        eq_(set(b1.subclasses), set())
        eq_(set(b1.all_superclasses), set())
        eq_(set(b1.all_subclasses), set())

        eq_(set(b2.superclasses), set())
        eq_(set(b2.subclasses), set())
        eq_(set(b2.all_superclasses), set())
        eq_(set(b2.all_subclasses), set())

        eq_(set(b3.superclasses), {t})
        eq_(set(b3.subclasses), set())
        eq_(set(b3.all_superclasses), {t})
        eq_(set(b3.all_subclasses), set())