mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #1470548: Add test for fragment producing with XMLGenerator.
This commit is contained in:
parent
67bfe80758
commit
a5f13d2a5f
1 changed files with 15 additions and 0 deletions
|
@ -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('<foo a="1.0">Hello</foo><bar b="2.0"></bar>')[len(self.xml('')):])
|
||||
|
||||
class StringXmlgenTest(XmlgenTest, unittest.TestCase):
|
||||
ioclass = StringIO
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue