summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sax.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2006-07-29 16:56:15 (GMT)
committerFred Drake <fdrake@acm.org>2006-07-29 16:56:15 (GMT)
commitfbdeaad06910a50d6f05da177949b9a451a1132a (patch)
tree373bae36b9be6328bc02c6f2a778e76a2f58e7ea /Lib/test/test_sax.py
parentc032ee939bae3662017f6ff359fb1ed7d207f3f6 (diff)
downloadcpython-fbdeaad06910a50d6f05da177949b9a451a1132a.zip
cpython-fbdeaad06910a50d6f05da177949b9a451a1132a.tar.gz
cpython-fbdeaad06910a50d6f05da177949b9a451a1132a.tar.bz2
expunge the xmlcore changes:
41667, 41668 - initial switch to xmlcore 47044 - mention of xmlcore in What's New 50687 - mention of xmlcore in the library reference re-apply xmlcore changes to xml: 41674 - line ending changes (re-applied manually), directory props 41677 - add cElementTree wrapper 41678 - PSF licensing for etree 41812 - whitespace normalization 42724 - fix svn:eol-style settings 43681, 43682 - remove Python version-compatibility cruft from minidom 46773 - fix encoding of \r\n\t in attr values in saxutils 47269 - added XMLParser alias for cElementTree compatibility additional tests were added in Lib/test/test_sax.py that failed with the xmlcore changes; these relate to SF bugs #1511497, #1513611
Diffstat (limited to 'Lib/test/test_sax.py')
-rw-r--r--Lib/test/test_sax.py75
1 files changed, 62 insertions, 13 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index 246d214..af4c7dd 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -1,17 +1,17 @@
# regression test for SAX 2.0 -*- coding: iso-8859-1 -*-
# $Id$
-from xmlcore.sax import make_parser, ContentHandler, \
- SAXException, SAXReaderNotAvailable, SAXParseException
+from xml.sax import make_parser, ContentHandler, \
+ SAXException, SAXReaderNotAvailable, SAXParseException
try:
make_parser()
except SAXReaderNotAvailable:
# don't try to test this module if we cannot create a parser
raise ImportError("no XML parsers available")
-from xmlcore.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
- XMLFilterBase
-from xmlcore.sax.expatreader import create_parser
-from xmlcore.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
+from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
+ XMLFilterBase
+from xml.sax.expatreader import create_parser
+from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from cStringIO import StringIO
from test.test_support import verify, verbose, TestFailed, findfile
import os
@@ -36,17 +36,17 @@ def test_make_parser2():
# Creating parsers several times in a row should succeed.
# Testing this because there have been failures of this kind
# before.
- from xmlcore.sax import make_parser
+ from xml.sax import make_parser
p = make_parser()
- from xmlcore.sax import make_parser
+ from xml.sax import make_parser
p = make_parser()
- from xmlcore.sax import make_parser
+ from xml.sax import make_parser
p = make_parser()
- from xmlcore.sax import make_parser
+ from xml.sax import make_parser
p = make_parser()
- from xmlcore.sax import make_parser
+ from xml.sax import make_parser
p = make_parser()
- from xmlcore.sax import make_parser
+ from xml.sax import make_parser
p = make_parser()
except:
return 0
@@ -108,7 +108,7 @@ def test_make_parser():
try:
# Creating a parser should succeed - it should fall back
# to the expatreader
- p = make_parser(['xmlcore.parsers.no_such_parser'])
+ p = make_parser(['xml.parsers.no_such_parser'])
except:
return 0
else:
@@ -671,6 +671,55 @@ def test_nsattrs_wattr():
attrs.getQNameByName((ns_uri, "attr")) == "ns:attr"
+# During the development of Python 2.5, an attempt to move the "xml"
+# package implementation to a new package ("xmlcore") proved painful.
+# The goal of this change was to allow applications to be able to
+# obtain and rely on behavior in the standard library implementation
+# of the XML support without needing to be concerned about the
+# availability of the PyXML implementation.
+#
+# While the existing import hackery in Lib/xml/__init__.py can cause
+# PyXML's _xmlpus package to supplant the "xml" package, that only
+# works because either implementation uses the "xml" package name for
+# imports.
+#
+# The move resulted in a number of problems related to the fact that
+# the import machinery's "package context" is based on the name that's
+# being imported rather than the __name__ of the actual package
+# containment; it wasn't possible for the "xml" package to be replaced
+# by a simple module that indirected imports to the "xmlcore" package.
+#
+# The following two tests exercised bugs that were introduced in that
+# attempt. Keeping these tests around will help detect problems with
+# other attempts to provide reliable access to the standard library's
+# implementation of the XML support.
+
+def test_sf_1511497():
+ # Bug report: http://www.python.org/sf/1511497
+ import sys
+ old_modules = sys.modules.copy()
+ for modname in sys.modules.keys():
+ if modname.startswith("xml."):
+ del sys.modules[modname]
+ try:
+ import xml.sax.expatreader
+ module = xml.sax.expatreader
+ return module.__name__ == "xml.sax.expatreader"
+ finally:
+ sys.modules.update(old_modules)
+
+def test_sf_1513611():
+ # Bug report: http://www.python.org/sf/1513611
+ sio = StringIO("invalid")
+ parser = make_parser()
+ from xml.sax import SAXParseException
+ try:
+ parser.parse(sio)
+ except SAXParseException:
+ return True
+ else:
+ return False
+
# ===== Main program
def make_test_output():