diff options
author | Eli Bendersky <eliben@gmail.com> | 2012-03-16 03:53:30 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2012-03-16 03:53:30 (GMT) |
commit | f996e775eaf22e6a6465e640a6de46ea74011bc0 (patch) | |
tree | 933b3ea33b18bc2101b883555ac587a221c02ee9 /Lib/test/test_xml_etree.py | |
parent | e53d977e8077759e8123da3da563e6b73392ed8b (diff) | |
download | cpython-f996e775eaf22e6a6465e640a6de46ea74011bc0.zip cpython-f996e775eaf22e6a6465e640a6de46ea74011bc0.tar.gz cpython-f996e775eaf22e6a6465e640a6de46ea74011bc0.tar.bz2 |
Closes Issue #14246: _elementtree parser will now handle io.StringIO
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r-- | Lib/test/test_xml_etree.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index fedf550..97fc690 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -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: |