From: Fred Drake Date: Fri, 13 Aug 2004 03:09:07 +0000 (+0000) Subject: include at least one example of an exception passing through pyexpat X-Git-Tag: v2.4a3~265 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5;p=python include at least one example of an exception passing through pyexpat --- diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index f281f8baad..44f9ee8e9b 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -311,3 +311,18 @@ parser.Parse("12345 ", 1) handler.check(["", "1", "", "", "2", "", "", "3", "", "4", "", "5", ""], "buffered text not properly split") + +# Test handling of exception from callback: +def StartElementHandler(name, attrs): + raise RuntimeError(name) + +parser = expat.ParserCreate() +parser.StartElementHandler = StartElementHandler + +try: + parser.Parse("", 1) +except RuntimeError, e: + if e.args[0] != "a": + print "Expected RuntimeError for element 'a'; found %r" % e.args[0] +else: + print "Expected RuntimeError for 'a'"