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
a80f761a
Commit
a80f761a
authored
Jan 22, 2013
by
Eli Bendersky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some tests for XPath numeric indexing
parent
076b97ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
Lib/test/test_xml_etree.py
Lib/test/test_xml_etree.py
+17
-0
No files found.
Lib/test/test_xml_etree.py
View file @
a80f761a
...
...
@@ -1776,6 +1776,23 @@ class ElementFindTest(unittest.TestCase):
# Issue #16922
self
.
assertEqual
(
ET
.
XML
(
'<tag><empty /></tag>'
).
findtext
(
'empty'
),
''
)
def
test_find_xpath
(
self
):
LINEAR_XML
=
'''
<body>
<tag class='a'/>
<tag class='b'/>
<tag class='c'/>
<tag class='d'/>
</body>'''
e
=
ET
.
XML
(
LINEAR_XML
)
# Test for numeric indexing and last()
self
.
assertEqual
(
e
.
find
(
'./tag[1]'
).
attrib
[
'class'
],
'a'
)
self
.
assertEqual
(
e
.
find
(
'./tag[2]'
).
attrib
[
'class'
],
'b'
)
self
.
assertEqual
(
e
.
find
(
'./tag[last()]'
).
attrib
[
'class'
],
'd'
)
self
.
assertEqual
(
e
.
find
(
'./tag[last()-1]'
).
attrib
[
'class'
],
'c'
)
self
.
assertEqual
(
e
.
find
(
'./tag[last()-2]'
).
attrib
[
'class'
],
'b'
)
def
test_findall
(
self
):
e
=
ET
.
XML
(
SAMPLE_XML
)
e
[
2
]
=
ET
.
XML
(
SAMPLE_SECTION
)
...
...
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