diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-25 11:47:20 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-25 11:47:20 (GMT) |
commit | bd9b56162ba6aa25b36bc8a642eb6c5c1e97cf50 (patch) | |
tree | f620856c97751b13985435ec6900ae098c6685d4 | |
parent | fca677a26aff3bce34b1b9b7662dd3a95cd285ba (diff) | |
parent | d9a550b5e14db2748f4fe089c2637c3462ad7d8d (diff) | |
download | cpython-bd9b56162ba6aa25b36bc8a642eb6c5c1e97cf50.zip cpython-bd9b56162ba6aa25b36bc8a642eb6c5c1e97cf50.tar.gz cpython-bd9b56162ba6aa25b36bc8a642eb6c5c1e97cf50.tar.bz2 |
Issue #1470548: Add test for fragment producing with XMLGenerator.
-rw-r--r-- | Lib/test/test_sax.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 98cc58e..05f66fd 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -493,6 +493,21 @@ class XmlgenTest: func(result) self.assertFalse(result.closed) + def test_xmlgen_fragment(self): + result = self.ioclass() + gen = XMLGenerator(result) + + # Don't call gen.startDocument() + gen.startElement("foo", {"a": "1.0"}) + gen.characters("Hello") + gen.endElement("foo") + gen.startElement("bar", {"b": "2.0"}) + gen.endElement("bar") + # Don't call gen.endDocument() + + self.assertEqual(result.getvalue(), + self.xml('<foo a="1.0">Hello</foo><bar b="2.0"></bar>')[len(self.xml('')):]) + class StringXmlgenTest(XmlgenTest, unittest.TestCase): ioclass = StringIO |