Ejemplo n.º 1
0
 def test_delete_enum_having_two_bundles(self):
     b1 = CBundle("B1")
     b2 = CBundle("B2")
     e1 = CEnum("e1", bundles=[b1, b2])
     e2 = CEnum("e2", bundles=[b2])
     e1.delete()
     eq_(set(b1.get_elements(type=CEnum)), set())
     eq_(set(b2.get_elements(type=CEnum)), {e2})
     eq_(set(e1.bundles), set())
     eq_(set(e2.bundles), {b2})
Ejemplo n.º 2
0
 def test_delete_enum_that_is_an_attribute_type(self):
     b1 = CBundle("B1")
     CBundle("B2")
     e1 = CEnum("E1", bundles=b1)
     e2 = CEnum("E2", bundles=b1)
     e3 = CEnum("E3", values=["1", "2"], bundles=b1)
     ea1 = CAttribute(type=e3, default="1")
     ea2 = CAttribute(type=e3)
     cl = CClass(self.mcl, attributes={"letters1": ea1, "letters2": ea2})
     o = CObject(cl, "o")
     e1.delete()
     e3.delete()
     try:
         ea1.default = "3"
         exception_expected_()
     except CException as e:
         eq_("cannot access named element that has been deleted", e.value)
     try:
         ea1.type = e1
         exception_expected_()
     except CException as e:
         eq_("cannot access named element that has been deleted", e.value)
     try:
         ea1.default = "3"
         exception_expected_()
     except CException as e:
         eq_("cannot access named element that has been deleted", e.value)
     try:
         ea1.type = e1
         exception_expected_()
     except CException as e:
         eq_("cannot access named element that has been deleted", e.value)
     try:
         ea1.type = e2
         exception_expected_()
     except CException as e:
         eq_("default value '1' incompatible with attribute's type 'E2'",
             e.value)
     try:
         o.set_value("letters1", "1")
         exception_expected_()
     except CException as e:
         eq_("cannot access named element that has been deleted", e.value)
     try:
         o.get_value("letters1")
         exception_expected_()
     except CException as e:
         eq_("cannot access named element that has been deleted", e.value)
Ejemplo n.º 3
0
    def test_delete_enum_from_bundle(self):
        b1 = CBundle("B1")
        e1 = CEnum("E1", bundles=b1)
        e1.delete()
        eq_(set(b1.get_elements(type=CEnum)), set())

        e1 = CEnum("E1", bundles=b1)
        e2 = CEnum("E2", bundles=b1)
        e3 = CEnum("E3", values=["1", "2"], bundles=b1)
        ea1 = CAttribute(type=e3, default="1")
        ea2 = CAttribute(type=e3)
        cl = CClass(self.mcl, attributes={"letters1": ea1, "letters2": ea2})
        o = CObject(cl, "o")

        e1.delete()
        eq_(set(b1.get_elements(type=CEnum)), {e2, e3})
        e3.delete()
        eq_(set(b1.get_elements(type=CEnum)), {e2})

        eq_(e3.name, None)
        eq_(e3.bundles, [])
        eq_(e3.values, [])
        eq_(set(cl.attributes), {ea1, ea2})
        try:
            # we just use list here, in order to not get a warning that ea1.default has no effect
            list([ea1.default])
            exception_expected_()
        except CException as e:
            eq_("cannot access named element that has been deleted", e.value)
        try:
            # we just use list here, in order to not get a warning that ea1.type has no effect
            list([ea1.type])
            exception_expected_()
        except CException as e:
            eq_("cannot access named element that has been deleted", e.value)
        try:
            ea1.default = "3"
            exception_expected_()
        except CException as e:
            eq_("cannot access named element that has been deleted", e.value)
        try:
            ea1.type = e1
            exception_expected_()
        except CException as e:
            eq_("cannot access named element that has been deleted", e.value)
        try:
            ea1.type = e2
            exception_expected_()
        except CException as e:
            eq_("default value '1' incompatible with attribute's type 'E2'",
                e.value)
        try:
            o.set_value("letters1", "1")
            exception_expected_()
        except CException as e:
            eq_("cannot access named element that has been deleted", e.value)
        try:
            o.get_value("letters1")
            exception_expected_()
        except CException as e:
            eq_("cannot access named element that has been deleted", e.value)