MCPcopy Index your code
hub / github.com/RustPython/RustPython / testRenameAttribute

Method testRenameAttribute

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

Source from the content-addressed store, hash-verified

1342
1343 @unittest.expectedFailure # TODO: RUSTPYTHON
1344 def testRenameAttribute(self):
1345 doc = parseString("<doc a='v'/>")
1346 elem = doc.documentElement
1347 attrmap = elem.attributes
1348 attr = elem.attributes['a']
1349
1350 # Simple renaming
1351 attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "b")
1352 self.confirm(attr.name == "b"
1353 and attr.nodeName == "b"
1354 and attr.localName is None
1355 and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE
1356 and attr.prefix is None
1357 and attr.value == "v"
1358 and elem.getAttributeNode("a") is None
1359 and elem.getAttributeNode("b").isSameNode(attr)
1360 and attrmap["b"].isSameNode(attr)
1361 and attr.ownerDocument.isSameNode(doc)
1362 and attr.ownerElement.isSameNode(elem))
1363
1364 # Rename to have a namespace, no prefix
1365 attr = doc.renameNode(attr, "http://xml.python.org/ns", "c")
1366 self.confirm(attr.name == "c"
1367 and attr.nodeName == "c"
1368 and attr.localName == "c"
1369 and attr.namespaceURI == "http://xml.python.org/ns"
1370 and attr.prefix is None
1371 and attr.value == "v"
1372 and elem.getAttributeNode("a") is None
1373 and elem.getAttributeNode("b") is None
1374 and elem.getAttributeNode("c").isSameNode(attr)
1375 and elem.getAttributeNodeNS(
1376 "http://xml.python.org/ns", "c").isSameNode(attr)
1377 and attrmap["c"].isSameNode(attr)
1378 and attrmap[("http://xml.python.org/ns", "c")].isSameNode(attr))
1379
1380 # Rename to have a namespace, with prefix
1381 attr = doc.renameNode(attr, "http://xml.python.org/ns2", "p:d")
1382 self.confirm(attr.name == "p:d"
1383 and attr.nodeName == "p:d"
1384 and attr.localName == "d"
1385 and attr.namespaceURI == "http://xml.python.org/ns2"
1386 and attr.prefix == "p"
1387 and attr.value == "v"
1388 and elem.getAttributeNode("a") is None
1389 and elem.getAttributeNode("b") is None
1390 and elem.getAttributeNode("c") is None
1391 and elem.getAttributeNodeNS(
1392 "http://xml.python.org/ns", "c") is None
1393 and elem.getAttributeNode("p:d").isSameNode(attr)
1394 and elem.getAttributeNodeNS(
1395 "http://xml.python.org/ns2", "d").isSameNode(attr)
1396 and attrmap["p:d"].isSameNode(attr)
1397 and attrmap[("http://xml.python.org/ns2", "d")].isSameNode(attr))
1398
1399 # Rename back to a simple non-NS node
1400 attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "e")
1401 self.confirm(attr.name == "e"

Callers

nothing calls this directly

Calls 9

confirmMethod · 0.95
parseStringFunction · 0.90
renameNodeMethod · 0.80
getAttributeNodeMethod · 0.80
isSameNodeMethod · 0.80
getAttributeNodeNSMethod · 0.80
assertRaisesMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected