示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)