[Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.6,1.7

Fred L. Drake python-dev@python.org
Sat, 23 Dec 2000 14:12:09 -0800


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

Modified Files:
	test_pyexpat.py 
Log Message:

The "context" parameter to the ExternalEntityRefParameter exposes internal
information from the Expat library that is not part of its public API.
Do not print this information as the format of the string may (and will)
change as Expat evolves.

Add additional tests to make sure the ParserCreate() function raises the
right exceptions on illegal parameters.


Index: test_pyexpat.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** test_pyexpat.py	2000/10/23 17:22:07	1.6
--- test_pyexpat.py	2000/12/23 22:12:07	1.7
***************
*** 51,55 ****
      def ExternalEntityRefHandler(self, *args):
          context, base, sysId, pubId = args
!         print 'External entity ref:', args
          return 1
  
--- 51,55 ----
      def ExternalEntityRefHandler(self, *args):
          context, base, sysId, pubId = args
!         print 'External entity ref:', args[1:]
          return 1
  
***************
*** 151,152 ****
--- 151,183 ----
      print '** Column', parser.ErrorColumnNumber
      print '** Byte', parser.ErrorByteIndex
+ 
+ 
+ # Tests that make sure we get errors when the namespace_separator value
+ # is illegal, and that we don't for good values:
+ print
+ print "Testing constructor for proper handling of namespace_separator values:"
+ expat.ParserCreate()
+ expat.ParserCreate(namespace_separator=None)
+ expat.ParserCreate(namespace_separator=' ')
+ print "Legal values tested o.k."
+ try:
+     expat.ParserCreate(namespace_separator=42)
+ except TypeError, e:
+     print "Caught expected TypeError:"
+     print e
+ else:
+     print "Failed to catch expected TypeError."
+ try:
+     expat.ParserCreate(namespace_separator='too long')
+ except ValueError, e:
+     print "Caught expected ValueError:"
+     print e
+ else:
+     print "Failed to catch expected ValueError."
+ try:
+     expat.ParserCreate(namespace_separator='') # too short
+ except ValueError, e:
+     print "Caught expected ValueError:"
+     print e
+ else:
+     print "Failed to catch expected ValueError."