diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-25 11:46:10 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-25 11:46:10 (GMT) |
commit | a5f13d2a5f03cb47da4daa85d0297a63897c92c9 (patch) | |
tree | 2cbeab802995949d149d1b369a116fe5212d2d1c /Lib/test | |
parent | 67bfe8075822b226793ce672751329dd658af9af (diff) | |
download | cpython-a5f13d2a5f03cb47da4daa85d0297a63897c92c9.zip cpython-a5f13d2a5f03cb47da4daa85d0297a63897c92c9.tar.gz cpython-a5f13d2a5f03cb47da4daa85d0297a63897c92c9.tar.bz2 |
Issue #1470548: Add test for fragment producing with XMLGenerator.
Diffstat (limited to 'Lib/test')
-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 218d519..bfa7d72 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 |