def test_clone_with_insert(): # difference of clone() to copy_entity() is: # - clone returns and unassigned entity without handle, owner or reactors # - copy_entity clones the entity and assigns the new entity to the same owner as the source and adds the entity # and it linked entities (ATTRIB & VERTEX) to the entity database, but does not adding entity to a layout, setting # owner tag is not enough to assign an entity to a layout, use Layout.add_entity() insert = Insert() insert.add_attrib('T1', 'value1', (0, 0)) clone = insert.copy() assert clone.dxf.handle is None assert clone.dxf.owner is None assert len(clone.attribs) == 1 attrib = clone.attribs[0] assert attrib.dxf.handle is None assert attrib.dxf.tag == 'T1' assert attrib.dxf.text == 'value1' # change cloned attrib attrib.dxf.tag = 'T2' attrib.dxf.text = 'value2' # source attrib is unchanged assert insert.attribs[0].dxf.tag == 'T1' assert insert.attribs[0].dxf.text == 'value1'
def test_add_attribs(): insert = Insert() assert insert.attribs_follow is False insert.add_attrib('T1', 'value1', (0, 0)) assert len(insert.attribs) == 1 assert insert.attribs_follow is True