mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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.
This commit is contained in:
parent
9a1a7dda8f
commit
1e0611b208
2 changed files with 44 additions and 4 deletions
|
@ -50,7 +50,7 @@ class Outputter:
|
|||
|
||||
def ExternalEntityRefHandler(self, *args):
|
||||
context, base, sysId, pubId = args
|
||||
print 'External entity ref:', args
|
||||
print 'External entity ref:', args[1:]
|
||||
return 1
|
||||
|
||||
def DefaultHandler(self, userData):
|
||||
|
@ -150,3 +150,34 @@ except expat.error:
|
|||
print '** Line', parser.ErrorLineNumber
|
||||
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."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue