Skip to content

Commit

Permalink
Issue #1470548: Add test for fragment producing with XMLGenerator.
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Feb 25, 2013
2 parents 9f10f56 + a5f13d2 commit d9a550b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Lib/test/test_sax.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ def func(out):
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

Expand Down

0 comments on commit d9a550b

Please sign in to comment.