From d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 13 Aug 2004 03:09:07 +0000 Subject: include at least one example of an exception passing through pyexpat --- Lib/test/test_pyexpat.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index f281f8b..44f9ee8 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'" -- cgit v0.12