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

Method testRenameElement

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

Source from the content-addressed store, hash-verified

1403 doc.unlink()
1404
1405 def testRenameElement(self):
1406 doc = parseString("<doc/>")
1407 elem = doc.documentElement
1408
1409 # Simple renaming
1410 elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "a")
1411 self.confirm(elem.tagName == "a"
1412 and elem.nodeName == "a"
1413 and elem.localName is None
1414 and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE
1415 and elem.prefix is None
1416 and elem.ownerDocument.isSameNode(doc))
1417
1418 # Rename to have a namespace, no prefix
1419 elem = doc.renameNode(elem, "http://xml.python.org/ns", "b")
1420 self.confirm(elem.tagName == "b"
1421 and elem.nodeName == "b"
1422 and elem.localName == "b"
1423 and elem.namespaceURI == "http://xml.python.org/ns"
1424 and elem.prefix is None
1425 and elem.ownerDocument.isSameNode(doc))
1426
1427 # Rename to have a namespace, with prefix
1428 elem = doc.renameNode(elem, "http://xml.python.org/ns2", "p:c")
1429 self.confirm(elem.tagName == "p:c"
1430 and elem.nodeName == "p:c"
1431 and elem.localName == "c"
1432 and elem.namespaceURI == "http://xml.python.org/ns2"
1433 and elem.prefix == "p"
1434 and elem.ownerDocument.isSameNode(doc))
1435
1436 # Rename back to a simple non-NS node
1437 elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "d")
1438 self.confirm(elem.tagName == "d"
1439 and elem.nodeName == "d"
1440 and elem.localName is None
1441 and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE
1442 and elem.prefix is None
1443 and elem.ownerDocument.isSameNode(doc))
1444
1445 self.checkRenameNodeSharedConstraints(doc, elem)
1446 doc.unlink()
1447
1448 def testRenameOther(self):
1449 # We have to create a comment node explicitly since not all DOM

Callers

nothing calls this directly

Calls 6

confirmMethod · 0.95
parseStringFunction · 0.90
renameNodeMethod · 0.80
isSameNodeMethod · 0.80
unlinkMethod · 0.45

Tested by

no test coverage detected