diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2000-10-24 15:35:07 (GMT) |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2000-10-24 15:35:07 (GMT) |
commit | 2fc5294911b808c002b2197c086528ed08cb6d98 (patch) | |
tree | fbb31c027f1c198089556cdf7f38c8f53c27ca6e | |
parent | 277a21150bb840fd4c7fffb49dd9b8edf0c520f8 (diff) | |
download | cpython-2fc5294911b808c002b2197c086528ed08cb6d98.zip cpython-2fc5294911b808c002b2197c086528ed08cb6d98.tar.gz cpython-2fc5294911b808c002b2197c086528ed08cb6d98.tar.bz2 |
Added some more tests here and there.
-rw-r--r-- | Lib/test/test_sax.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 26fd873..59e14c5 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -29,6 +29,29 @@ def confirm(outcome, name): print "Failed", name fails = fails + 1 +def test_make_parser2(): + try: + # Creating parsers several times in a row should succeed. + # Testing this because there have been failures of this kind + # before. + from xml.sax import make_parser + p = make_parser() + from xml.sax import make_parser + p = make_parser() + from xml.sax import make_parser + p = make_parser() + from xml.sax import make_parser + p = make_parser() + from xml.sax import make_parser + p = make_parser() + from xml.sax import make_parser + p = make_parser() + except: + return 0 + else: + return p + + # =========================================================================== # # saxutils tests @@ -313,6 +336,67 @@ def test_expat_inpsource_stream(): return result.getvalue() == xml_test_out +# ===== IncrementalParser support + +def test_expat_incremental(): + result = StringIO() + xmlgen = XMLGenerator(result) + parser = create_parser() + parser.setContentHandler(xmlgen) + + parser.feed("<doc>") + parser.feed("</doc>") + parser.close() + + return result.getvalue() == start + "<doc></doc>" + +def test_expat_incremental_reset(): + result = StringIO() + xmlgen = XMLGenerator(result) + parser = create_parser() + parser.setContentHandler(xmlgen) + + parser.feed("<doc>") + parser.feed("text") + + result = StringIO() + xmlgen = XMLGenerator(result) + parser.setContentHandler(xmlgen) + parser.reset() + + parser.feed("<doc>") + parser.feed("text") + parser.feed("</doc>") + parser.close() + + return result.getvalue() == start + "<doc>text</doc>" + +# ===== Locator support + +def test_expat_locator_noinfo(): + result = StringIO() + xmlgen = XMLGenerator(result) + parser = create_parser() + parser.setContentHandler(xmlgen) + + parser.feed("<doc>") + parser.feed("</doc>") + parser.close() + + return parser.getSystemId() == None and \ + parser.getPublicId() == None and \ + parser.getLineNumber() == 1 + +def test_expat_locator_withinfo(): + result = StringIO() + xmlgen = XMLGenerator(result) + parser = create_parser() + parser.setContentHandler(xmlgen) + parser.parse(findfile("test.xml")) + + return parser.getSystemId() == findfile("test.xml") and \ + parser.getPublicId() == None + # =========================================================================== # |