#!/usr/bin/env python
import coral

st = coral.Project()

m = coral.lang.UML14.Model()
c = coral.lang.UML14.Class()
a = coral.lang.UML14.Attribute()

t = coral.lang.UML14.Class()
a.type = t

m.ownedElement.add(c)

t.__setProject__(st)

coral.TransactionManager.beginModifyCmd()
try:
    c.feature.add(a)
finally:
    coral.TransactionManager.endModifyCmd()

assert a.type == t

coral.TransactionManager.beginModifyCmd()
try:
    m.ownedElement=[]
finally:
    coral.TransactionManager.endModifyCmd()
    

assert c.feature.size() == 1
assert a.owner == c
assert a.type is None
assert t.typedFeature.size() == 0
