1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/nodes.py Tue May 17 14:43:35 2005 +0000
1.3 @@ -0,0 +1,42 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"Test of elements and attribute interfaces."
1.7 +
1.8 +import libxml2dom
1.9 +
1.10 +d = libxml2dom.parseString("<ddd:doc xmlns:ddd='http://ddd'/>")
1.11 +e = d.xpath("*")[0]
1.12 +assert e.parentNode == d
1.13 +assert e.namespaceURI == "http://ddd"
1.14 +assert e.nodeName == e.tagName == "ddd:doc"
1.15 +assert e.localName == "doc"
1.16 +e.setAttributeNS("http://xxx", "xxx:x", "y")
1.17 +assert e.getAttributeNS("http://xxx", "x") == "y"
1.18 +l = e.xpath("@*")
1.19 +assert len(l) == 1
1.20 +a = l[0]
1.21 +assert a.parentNode == e
1.22 +assert a.namespaceURI == "http://xxx"
1.23 +assert a.nodeName == "xxx:x"
1.24 +assert a.localName == "x"
1.25 +assert a.nodeValue == a.value == "y"
1.26 +a2 = d.createAttributeNS("http://aaa", "aaa:a")
1.27 +a2.nodeValue = "b"
1.28 +assert a2.namespaceURI == "http://aaa"
1.29 +assert a2.nodeName == "aaa:a"
1.30 +assert a2.localName == "a"
1.31 +assert a2.nodeValue == a2.value == "b"
1.32 +e.setAttributeNodeNS(a2)
1.33 +l2 = e.xpath("@*")
1.34 +assert len(l2) == 2
1.35 +e.setAttributeNS("http://ccc", "ccc:c", "d")
1.36 +assert e.getAttributeNS("http://ccc", "c") == "d"
1.37 +l3 = e.xpath("@*")
1.38 +assert len(l3) == 3
1.39 +e.setAttribute("p", "q")
1.40 +assert e.getAttribute("p") == "q"
1.41 +l4 = e.xpath("@*")
1.42 +assert len(l4) == 4
1.43 +print d.toString()
1.44 +
1.45 +# vim: tabstop=4 expandtab shiftwidth=4