summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sax.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2000-10-06 17:41:52 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2000-10-06 17:41:52 (GMT)
commit962c9e7f9188c75a3889fcc7fd29fb1626e278d0 (patch)
tree3656fb89cdb496f4015152b35951276f432df3c7 /Lib/test/test_sax.py
parent75698a4937130b0ca8019c553a4be7f02eb5ab0a (diff)
downloadcpython-962c9e7f9188c75a3889fcc7fd29fb1626e278d0.zip
cpython-962c9e7f9188c75a3889fcc7fd29fb1626e278d0.tar.gz
cpython-962c9e7f9188c75a3889fcc7fd29fb1626e278d0.tar.bz2
Add SAXReaderNotAvailable, and use it to distinguish between an
ImportError, and a missing driver.
Diffstat (limited to 'Lib/test/test_sax.py')
-rw-r--r--Lib/test/test_sax.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index 1760eb2..b3576ab 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -2,10 +2,15 @@
# regression test for SAX 2.0
# $Id$
+from xml.sax import make_parser, ContentHandler
+try:
+ make_parser()
+except xml.sax.SAXReaderNotAvailable:
+ # don't try to test this module if we cannot create a parser
+ raise ImportError("no XML parsers available")
from xml.sax.saxutils import XMLGenerator, escape, XMLFilterBase
from xml.sax.expatreader import create_parser
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
-from xml.sax.handler import ContentHandler
from cStringIO import StringIO
from test_support import verbose, TestFailed, findfile
@@ -41,6 +46,17 @@ def test_escape_all():
def test_escape_extra():
return escape("Hei på deg", {"å" : "&aring;"}) == "Hei p&aring; deg"
+def test_make_parser():
+ try:
+ # Creating a parser should succeed - it should fall back
+ # to the expatreader
+ p = make_parser(['xml.parsers.no_such_parser'])
+ except:
+ return 0
+ else:
+ return p
+
+
# ===== XMLGenerator
start = '<?xml version="1.0" encoding="iso-8859-1"?>\n'