From a5f13d2a5f03cb47da4daa85d0297a63897c92c9 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 25 Feb 2013 13:46:10 +0200 Subject: [PATCH] Issue #1470548: Add test for fragment producing with XMLGenerator. --- Lib/test/test_sax.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 218d5199fbb..bfa7d72d164 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('Hello')[len(self.xml('')):]) + class StringXmlgenTest(XmlgenTest, unittest.TestCase): ioclass = StringIO