MCPcopy Index your code
hub / github.com/python/cpython / testSetIdAttributeNode

Method testSetIdAttributeNode

Lib/test/test_minidom.py:1632–1666  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1630 and a2.isId)
1631
1632 def testSetIdAttributeNode(self):
1633 NS1 = "http://xml.python.org/ns1"
1634 NS2 = "http://xml.python.org/ns2"
1635 doc = parseString("<doc"
1636 " xmlns:ns1='" + NS1 + "'"
1637 " xmlns:ns2='" + NS2 + "'"
1638 " ns1:a1='v' ns2:a2='w'/>")
1639 e = doc.documentElement
1640 a1 = e.getAttributeNodeNS(NS1, "a1")
1641 a2 = e.getAttributeNodeNS(NS2, "a2")
1642 self.confirm(doc.getElementById("v") is None
1643 and not a1.isId
1644 and not a2.isId)
1645 e.setIdAttributeNode(a1)
1646 self.confirm(e.isSameNode(doc.getElementById("v"))
1647 and a1.isId
1648 and not a2.isId)
1649 e.setIdAttributeNode(a2)
1650 self.confirm(e.isSameNode(doc.getElementById("v"))
1651 and e.isSameNode(doc.getElementById("w"))
1652 and a1.isId
1653 and a2.isId)
1654 # replace the a1 node; the new node should *not* be an ID
1655 a3 = doc.createAttributeNS(NS1, "a1")
1656 a3.value = "v"
1657 e.setAttributeNode(a3)
1658 self.assertTrue(e.isSameNode(doc.getElementById("w")))
1659 self.assertFalse(a1.isId)
1660 self.assertTrue(a2.isId)
1661 self.assertFalse(a3.isId)
1662 self.assertIsNone(doc.getElementById("v"))
1663 # renaming an attribute should not affect its ID-ness:
1664 doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
1665 self.confirm(e.isSameNode(doc.getElementById("w"))
1666 and a2.isId)
1667
1668 def assert_recursive_equal(self, doc, doc2):
1669 stack = [(doc, doc2)]

Callers

nothing calls this directly

Calls 12

confirmMethod · 0.95
parseStringFunction · 0.90
getAttributeNodeNSMethod · 0.80
getElementByIdMethod · 0.80
setIdAttributeNodeMethod · 0.80
isSameNodeMethod · 0.80
createAttributeNSMethod · 0.80
setAttributeNodeMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertIsNoneMethod · 0.80
renameNodeMethod · 0.80

Tested by

no test coverage detected