Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
791a5341
Commit
791a5341
authored
Oct 25, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #28314: Added tests for xml.etree.ElementTree.Element.getiterator().
parents
34d1f533
db71dea8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
Lib/test/test_xml_etree.py
Lib/test/test_xml_etree.py
+32
-0
No files found.
Lib/test/test_xml_etree.py
View file @
791a5341
...
...
@@ -2195,9 +2195,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
(
'''
<document>
<house>
<room>bedroom1</room>
<room>bedroom2</room>
</house>
<shed>nothing here
</shed>
<house>
<room>bedroom8</room>
</house>
</document>'''
)
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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment