Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d9a550b

Browse files
committedFeb 25, 2013
Issue #1470548: Add test for fragment producing with XMLGenerator.
2 parents 9f10f56 + a5f13d2 commit d9a550b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎Lib/test/test_sax.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,21 @@ def func(out):
493493
func(result)
494494
self.assertFalse(result.closed)
495495

496+
def test_xmlgen_fragment(self):
497+
result = self.ioclass()
498+
gen = XMLGenerator(result)
499+
500+
# Don't call gen.startDocument()
501+
gen.startElement("foo", {"a": "1.0"})
502+
gen.characters("Hello")
503+
gen.endElement("foo")
504+
gen.startElement("bar", {"b": "2.0"})
505+
gen.endElement("bar")
506+
# Don't call gen.endDocument()
507+
508+
self.assertEqual(result.getvalue(),
509+
self.xml('<foo a="1.0">Hello</foo><bar b="2.0"></bar>')[len(self.xml('')):])
510+
496511
class StringXmlgenTest(XmlgenTest, unittest.TestCase):
497512
ioclass = StringIO
498513

0 commit comments

Comments
 (0)
Please sign in to comment.