Commit cbf53715 authored by Fred Drake's avatar Fred Drake

Be more flexible about which versions of Expat / pyexpat are supported.

I *think* this fixes the misleading test failure on Windows Python 2.1.*.
parent 0d3e7e88
...@@ -92,7 +92,10 @@ class XMLParserTestCase(unittest.TestCase): ...@@ -92,7 +92,10 @@ class XMLParserTestCase(unittest.TestCase):
parser.parseStream(SegmentedFile(source)) parser.parseStream(SegmentedFile(source))
else: else:
parser.parseString(source) parser.parseString(source)
self.assertEquals(parser.get_events(),events) if utils.oldexpat:
while events[0][0] in ('decl', 'doctype'):
del events[0]
self.assertEquals(parser.get_events(), events)
def _run_check_extra(self, source, events): def _run_check_extra(self, source, events):
self._run_check(source, events, EventCollectorExtra) self._run_check(source, events, EventCollectorExtra)
......
...@@ -13,6 +13,7 @@ import unittest ...@@ -13,6 +13,7 @@ import unittest
# Set skipxml to true if an XML parser could not be found. # Set skipxml to true if an XML parser could not be found.
pyexpat = None
skipxml = 0 skipxml = 0
try: try:
import pyexpat import pyexpat
...@@ -22,6 +23,23 @@ except ImportError: ...@@ -22,6 +23,23 @@ except ImportError:
import xml.parsers.pyexpat import xml.parsers.pyexpat
except ImportError: except ImportError:
skipxml = 1 skipxml = 1
else:
pyexpat = xml.parsers.pyexpat
# Set oldexpat if the StartDoctypeDeclHandler and XmlDeclHandler are
# not supported. The tests need to know whether the events reported
# by those handlers should be expected, but need to make sure the
# right thing is returned if they are.
oldexpat = 0
if pyexpat is not None:
p = pyexpat.ParserCreate()
# Can't use hasattr() since pyexpat supports the handler
# attributes in a broken way.
try:
p.StartDoctypeDeclHandler = None
except AttributeError:
oldexpat = 1
def run_suite(suite, outf=None, errf=None): def run_suite(suite, outf=None, errf=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment