[Python-checkins] cpython (3.3): Add some tests for XPath numeric indexing
eli.bendersky
python-checkins at python.org
Tue Jan 22 15:15:39 CET 2013
http://hg.python.org/cpython/rev/2e2351733a6f
changeset: 81654:2e2351733a6f
branch: 3.3
parent: 81652:6b1e393ba874
user: Eli Bendersky <eliben at gmail.com>
date: Tue Jan 22 06:12:54 2013 -0800
summary:
Add some tests for XPath numeric indexing
files:
Lib/test/test_xml_etree.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1776,6 +1776,23 @@
# 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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list