[Python-checkins] CVS: python/dist/src/Lib/test test_minidom.py,1.27,1.28

Fred L. Drake fdrake@users.sourceforge.net
Fri, 28 Sep 2001 13:31:52 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv29274

Modified Files:
	test_minidom.py 
Log Message:
Update the xml.dom.minidom tests to cover the DOM-compliant parts of the
NodeList interface.

Index: test_minidom.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** test_minidom.py	2001/06/03 14:27:02	1.27
--- test_minidom.py	2001/09/28 20:31:50	1.28
***************
*** 45,50 ****
--- 45,53 ----
      root.insertBefore(nelem, elem)
      confirm(len(root.childNodes) == 2
+             and root.childNodes.length == 2
              and root.childNodes[0] is nelem
+             and root.childNodes.item(0) is nelem
              and root.childNodes[1] is elem
+             and root.childNodes.item(1) is elem
              and root.firstChild is nelem
              and root.lastChild is elem
***************
*** 54,59 ****
--- 57,65 ----
      root.insertBefore(nelem, None)
      confirm(len(root.childNodes) == 3
+             and root.childNodes.length == 3
              and root.childNodes[1] is elem
+             and root.childNodes.item(1) is elem
              and root.childNodes[2] is nelem
+             and root.childNodes.item(2) is nelem
              and root.lastChild is nelem
              and nelem.previousSibling is elem
***************
*** 63,68 ****
--- 69,77 ----
      root.insertBefore(nelem2, nelem)
      confirm(len(root.childNodes) == 4
+             and root.childNodes.length == 4
              and root.childNodes[2] is nelem2
+             and root.childNodes.item(2) is nelem2
              and root.childNodes[3] is nelem
+             and root.childNodes.item(3) is nelem
              and nelem2.nextSibling is nelem
              and nelem.previousSibling is nelem2
***************
*** 370,373 ****
--- 379,383 ----
      dom, clone = _setupCloneElement(0)
      confirm(len(clone.childNodes) == 0
+             and clone.childNodes.length == 0
              and clone.parentNode is None
              and clone.toxml() == '<doc attr="value"/>'
***************
*** 378,381 ****
--- 388,392 ----
      dom, clone = _setupCloneElement(1)
      confirm(len(clone.childNodes) == 1
+             and clone.childNodes.length == 1
              and clone.parentNode is None
              and clone.toxml() == '<doc attr="value"><foo/></doc>'
***************
*** 433,439 ****
      root.appendChild(doc.createTextNode("first"))
      root.appendChild(doc.createTextNode("second"))
!     confirm(len(root.childNodes) == 2, "testNormalize -- preparation")
      doc.normalize()
      confirm(len(root.childNodes) == 1
              and root.firstChild is root.lastChild
              and root.firstChild.data == "firstsecond"
--- 444,452 ----
      root.appendChild(doc.createTextNode("first"))
      root.appendChild(doc.createTextNode("second"))
!     confirm(len(root.childNodes) == 2
!             and root.childNodes.length == 2, "testNormalize -- preparation")
      doc.normalize()
      confirm(len(root.childNodes) == 1
+             and root.childNodes.length == 1
              and root.firstChild is root.lastChild
              and root.firstChild.data == "firstsecond"
***************
*** 445,449 ****
      root.appendChild(doc.createTextNode(""))
      doc.normalize()
!     confirm(len(root.childNodes) == 0,
              "testNormalize -- single empty node removed")
      doc.unlink()
--- 458,463 ----
      root.appendChild(doc.createTextNode(""))
      doc.normalize()
!     confirm(len(root.childNodes) == 0
!             and root.childNodes.length == 0,
              "testNormalize -- single empty node removed")
      doc.unlink()
***************
*** 476,479 ****
--- 490,505 ----
              elm3.parentNode is elm2b, "testParents")
  
+     doc.unlink()
+ 
+ def testNodeListItem():
+     doc = parseString("<doc><e/><e/></doc>")
+     children = doc.childNodes
+     docelem = children[0]
+     confirm(children[0] is children.item(0)
+             and children.item(1) is None
+             and docelem.childNodes.item(0) is docelem.childNodes[0]
+             and docelem.childNodes.item(1) is docelem.childNodes[1]
+             and docelem.childNodes.item(0).childNodes.item(0) is None,
+             "test NodeList.item()")
      doc.unlink()