def test_changeattr(self): el = MeiElement("mei") el.addAttribute("meiversion", "2011-05") self.assertTrue(el.hasAttribute("meiversion")) self.assertEqual("2011-05", el.getAttribute("meiversion").value) at = el.getAttribute("meiversion") at.value = "2012" self.assertEqual("2012", el.getAttribute("meiversion").value)
def test_copy_constructor(self): note = MeiElement("note") note2 = note # check that regular pointer referencing in Python works on MeiElements self.assertEqual(note2, note) note.addAttribute('pname', 'c') note3 = MeiElement(note) # check that they have been properly copied self.assertNotEqual(note3, note) # check that the attributes copied are not the same self.assertNotEqual(note3.getAttribute('pname'), note.getAttribute('pname')) # check that the attribute values copied are the same self.assertEqual(note3.getAttribute('pname').value, note.getAttribute('pname').value)
def test_changechildvalue(self): """ Check if we can replace an attribute value in-place""" p = MeiElement("layer") el1 = MeiElement("note") el2 = MeiElement("note") p.addChild(el1) p.addChild(el2) el1.addAttribute("pname", "c") self.assertEqual("c", p.children[0].getAttribute("pname").value) el1.getAttribute("pname").value = "d" self.assertEqual("d", p.children[0].getAttribute("pname").value)