[Python-checkins] python/dist/src/Lib/test test_minidom.py,1.31,1.31.6.1

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Thu, 26 Sep 2002 08:53:02 -0700


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

Modified Files:
      Tag: release22-maint
	test_minidom.py 
Log Message:
Backport patches for versions 1.33, 1.35, and 1.36 from the trunk:

revision 1.36:
If PyXML is installed, there is no Node.allnodes, so that portion of
the test should be skipped if that's the case.

revision 1.35:
Remove duplicate checks of the Node.allnodes variable.

revision 1.33:
Follow PyXML: Remove all prints from successful tests.  This means we can
also drop the output file.


Index: test_minidom.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v
retrieving revision 1.31
retrieving revision 1.31.6.1
diff -C2 -d -r1.31 -r1.31.6.1
*** test_minidom.py	6 Dec 2001 18:27:48 -0000	1.31
--- test_minidom.py	26 Sep 2002 15:52:59 -0000	1.31.6.1
***************
*** 18,24 ****
  
  def confirm(test, testname = "Test"):
!     if test:
!         print "Passed " + testname
!     else:
          print "Failed " + testname
          raise Exception
--- 18,22 ----
  
  def confirm(test, testname = "Test"):
!     if not test:
          print "Failed " + testname
          raise Exception
***************
*** 354,358 ****
      confirm(string1.find("slash:abc") != -1)
      dom.unlink()
-     confirm(len(Node.allnodes) == 0)
  
  def testAttributeRepr():
--- 352,355 ----
***************
*** 362,366 ****
      confirm(str(node) == repr(node))
      dom.unlink()
-     confirm(len(Node.allnodes) == 0)
  
  def testTextNodeRepr(): pass
--- 359,362 ----
***************
*** 372,376 ****
      dom.unlink()
      confirm(str == domstr)
-     confirm(len(Node.allnodes) == 0)
  
  def testProcessingInstruction(): pass
--- 368,371 ----
***************
*** 390,394 ****
          doc.appendChild(elem)
      except HierarchyRequestErr:
!         print "Caught expected exception when adding extra document element."
      else:
          print "Failed to catch expected exception when" \
--- 385,389 ----
          doc.appendChild(elem)
      except HierarchyRequestErr:
!         pass
      else:
          print "Failed to catch expected exception when" \
***************
*** 614,617 ****
--- 609,633 ----
  failed = []
  
+ try:
+     Node.allnodes
+ except AttributeError:
+     # We don't actually have the minidom from the standard library,
+     # but are picking up the PyXML version from site-packages.
+     def check_allnodes():
+         pass
+ else:
+     def check_allnodes():
+         confirm(len(Node.allnodes) == 0,
+                 "assertion: len(Node.allnodes) == 0")
+         if len(Node.allnodes):
+             print "Garbage left over:"
+             if verbose:
+                 print Node.allnodes.items()[0:10]
+             else:
+                 # Don't print specific nodes if repeatable results
+                 # are needed
+                 print len(Node.allnodes)
+         Node.allnodes = {}
+ 
  for name in names:
      if name.startswith("test"):
***************
*** 619,634 ****
          try:
              func()
!             print "Test Succeeded", name
!             confirm(len(Node.allnodes) == 0,
!                     "assertion: len(Node.allnodes) == 0")
!             if len(Node.allnodes):
!                 print "Garbage left over:"
!                 if verbose:
!                     print Node.allnodes.items()[0:10]
!                 else:
!                     # Don't print specific nodes if repeatable results
!                     # are needed
!                     print len(Node.allnodes)
!             Node.allnodes = {}
          except:
              failed.append(name)
--- 635,639 ----
          try:
              func()
!             check_allnodes()
          except:
              failed.append(name)
***************
*** 643,650 ****
      for name in failed:
          print "  " + name
-     print
- else:
-     print "All tests succeeded"
- 
- Node.debug = None # Delete debug output collected in a StringIO object
- Node._debug = 0   # And reset debug mode
--- 648,649 ----