[Python-checkins] cpython (3.2): Issue #1470548: Add test for fragment producing with XMLGenerator.

serhiy.storchaka python-checkins at python.org
Mon Feb 25 12:49:20 CET 2013


http://hg.python.org/cpython/rev/1c03e499cdc2
changeset:   82379:1c03e499cdc2
branch:      3.2
parent:      82373:d6a26cd93825
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Feb 25 13:46:10 2013 +0200
summary:
  Issue #1470548: Add test for fragment producing with XMLGenerator.

files:
  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
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -493,6 +493,21 @@
         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
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list