(self)
| 1326 | xml.dom.EMPTY_NAMESPACE, "foo") |
| 1327 | |
| 1328 | def testRenameAttribute(self): |
| 1329 | doc = parseString("<doc a='v'/>") |
| 1330 | elem = doc.documentElement |
| 1331 | attrmap = elem.attributes |
| 1332 | attr = elem.attributes['a'] |
| 1333 | |
| 1334 | # Simple renaming |
| 1335 | attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "b") |
| 1336 | self.confirm(attr.name == "b" |
| 1337 | and attr.nodeName == "b" |
| 1338 | and attr.localName is None |
| 1339 | and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE |
| 1340 | and attr.prefix is None |
| 1341 | and attr.value == "v" |
| 1342 | and elem.getAttributeNode("a") is None |
| 1343 | and elem.getAttributeNode("b").isSameNode(attr) |
| 1344 | and attrmap["b"].isSameNode(attr) |
| 1345 | and attr.ownerDocument.isSameNode(doc) |
| 1346 | and attr.ownerElement.isSameNode(elem)) |
| 1347 | |
| 1348 | # Rename to have a namespace, no prefix |
| 1349 | attr = doc.renameNode(attr, "http://xml.python.org/ns", "c") |
| 1350 | self.confirm(attr.name == "c" |
| 1351 | and attr.nodeName == "c" |
| 1352 | and attr.localName == "c" |
| 1353 | and attr.namespaceURI == "http://xml.python.org/ns" |
| 1354 | and attr.prefix is None |
| 1355 | and attr.value == "v" |
| 1356 | and elem.getAttributeNode("a") is None |
| 1357 | and elem.getAttributeNode("b") is None |
| 1358 | and elem.getAttributeNode("c").isSameNode(attr) |
| 1359 | and elem.getAttributeNodeNS( |
| 1360 | "http://xml.python.org/ns", "c").isSameNode(attr) |
| 1361 | and attrmap["c"].isSameNode(attr) |
| 1362 | and attrmap[("http://xml.python.org/ns", "c")].isSameNode(attr)) |
| 1363 | |
| 1364 | # Rename to have a namespace, with prefix |
| 1365 | attr = doc.renameNode(attr, "http://xml.python.org/ns2", "p:d") |
| 1366 | self.confirm(attr.name == "p:d" |
| 1367 | and attr.nodeName == "p:d" |
| 1368 | and attr.localName == "d" |
| 1369 | and attr.namespaceURI == "http://xml.python.org/ns2" |
| 1370 | and attr.prefix == "p" |
| 1371 | and attr.value == "v" |
| 1372 | and elem.getAttributeNode("a") is None |
| 1373 | and elem.getAttributeNode("b") is None |
| 1374 | and elem.getAttributeNode("c") is None |
| 1375 | and elem.getAttributeNodeNS( |
| 1376 | "http://xml.python.org/ns", "c") is None |
| 1377 | and elem.getAttributeNode("p:d").isSameNode(attr) |
| 1378 | and elem.getAttributeNodeNS( |
| 1379 | "http://xml.python.org/ns2", "d").isSameNode(attr) |
| 1380 | and attrmap["p:d"].isSameNode(attr) |
| 1381 | and attrmap[("http://xml.python.org/ns2", "d")].isSameNode(attr)) |
| 1382 | |
| 1383 | # Rename back to a simple non-NS node |
| 1384 | attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "e") |
| 1385 | self.confirm(attr.name == "e" |
nothing calls this directly
no test coverage detected