mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Closes Issue #14246: _elementtree parser will now handle io.StringIO
This commit is contained in:
parent
e53d977e80
commit
f996e775ea
2 changed files with 36 additions and 1 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import sys
|
||||
import html
|
||||
import io
|
||||
import unittest
|
||||
|
||||
from test import support
|
||||
|
|
@ -2026,6 +2027,18 @@ class ElementSlicingTest(unittest.TestCase):
|
|||
del e[::2]
|
||||
self.assertEqual(self._subelem_tags(e), ['a1'])
|
||||
|
||||
|
||||
class StringIOTest(unittest.TestCase):
|
||||
def test_read_from_stringio(self):
|
||||
tree = ET.ElementTree()
|
||||
stream = io.StringIO()
|
||||
stream.write('''<?xml version="1.0"?><site></site>''')
|
||||
stream.seek(0)
|
||||
tree.parse(stream)
|
||||
|
||||
self.assertEqual(tree.getroot().tag, 'site')
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
@ -2077,6 +2090,7 @@ def test_main(module=pyET):
|
|||
|
||||
test_classes = [
|
||||
ElementSlicingTest,
|
||||
StringIOTest,
|
||||
ElementTreeTest,
|
||||
TreeBuilderTest]
|
||||
if module is pyET:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue