Commit d9a550b5 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #1470548: Add test for fragment producing with XMLGenerator.

parents 9f10f56d a5f13d2a
...@@ -493,6 +493,21 @@ class XmlgenTest: ...@@ -493,6 +493,21 @@ class XmlgenTest:
func(result) func(result)
self.assertFalse(result.closed) 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): class StringXmlgenTest(XmlgenTest, unittest.TestCase):
ioclass = StringIO ioclass = StringIO
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment