diff options
author | Fred Drake <fdrake@acm.org> | 2004-08-13 03:09:07 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-08-13 03:09:07 (GMT) |
commit | d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5 (patch) | |
tree | 7c4ad79221d37714b3afb6d4e385bd7e3350456f /Lib/test/test_pyexpat.py | |
parent | 2e56c8a2605c91b8f55db4327748a28272ba0f8d (diff) | |
download | cpython-d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5.zip cpython-d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5.tar.gz cpython-d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5.tar.bz2 |
include at least one example of an exception passing through pyexpat
Diffstat (limited to 'Lib/test/test_pyexpat.py')
-rw-r--r-- | Lib/test/test_pyexpat.py | 15 |
1 files changed, 15 insertions, 0 deletions
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("<a>1<b/>2<c></c>3<!--abc-->4<!--def-->5</a> ", 1) handler.check(["<a>", "1", "<b>", "</b>", "2", "<c>", "</c>", "3", "<!--abc-->", "4", "<!--def-->", "5", "</a>"], "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("<a><b><c/></b></a>", 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'" |