From 036fb15435a2b5fb8acb200ee694b1d50c87a3a9 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 25 Oct 2016 10:37:01 +0300 Subject: Issue #28314: Added tests for xml.etree.ElementTree.Element.getiterator(). --- Lib/test/test_xml_etree.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index fbfc0b0..6c7616b 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -2191,9 +2191,41 @@ class ElementIterTest(unittest.TestCase): # make sure both tag=None and tag='*' return all tags all_tags = ['document', 'house', 'room', 'room', 'shed', 'house', 'room'] + self.assertEqual(summarize_list(doc.iter()), all_tags) self.assertEqual(self._ilist(doc), all_tags) self.assertEqual(self._ilist(doc, '*'), all_tags) + def test_getiterator(self): + doc = ET.XML(''' + + + bedroom1 + bedroom2 + + nothing here + + + bedroom8 + + ''') + + self.assertEqual(summarize_list(doc.getiterator('room')), + ['room'] * 3) + self.assertEqual(summarize_list(doc.getiterator('house')), + ['house'] * 2) + + # test that getiterator also accepts 'tag' as a keyword arg + self.assertEqual( + summarize_list(doc.getiterator(tag='room')), + ['room'] * 3) + + # make sure both tag=None and tag='*' return all tags + all_tags = ['document', 'house', 'room', 'room', + 'shed', 'house', 'room'] + self.assertEqual(summarize_list(doc.getiterator()), all_tags) + self.assertEqual(summarize_list(doc.getiterator(None)), all_tags) + self.assertEqual(summarize_list(doc.getiterator('*')), all_tags) + def test_copy(self): a = ET.Element('a') it = a.iter() -- cgit v0.12