[ZPT] CVS: Zope/lib/python/TAL/tests - test_xmlparser.py:1.6 utils.py:1.5
Fred L. Drake, Jr.
fdrake@acm.org
Tue, 16 Apr 2002 13:49:41 -0400
Update of /cvs-repository/Zope/lib/python/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv31411
Modified Files:
test_xmlparser.py utils.py
Log Message:
Be more flexible about which versions of Expat / pyexpat are supported.
I *think* this fixes the misleading test failure on Windows Python 2.1.*.
=== Zope/lib/python/TAL/tests/test_xmlparser.py 1.5 => 1.6 ===
else:
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):
self._run_check(source, events, EventCollectorExtra)
=== Zope/lib/python/TAL/tests/utils.py 1.4 => 1.5 ===
# Set skipxml to true if an XML parser could not be found.
+pyexpat = None
skipxml = 0
try:
import pyexpat
@@ -22,6 +23,23 @@
import xml.parsers.pyexpat
except ImportError:
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):