summaryrefslogtreecommitdiff
path: root/Lib/test/test_xml_etree.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-01-24 06:29:26 -0800
committerEli Bendersky <eliben@gmail.com>2013-01-24 06:29:26 -0800
commitd9d578479613bd744b720f2b5d2ab6877cbfe508 (patch)
treea3e7f37a61c3fe80b0719b2ca9efa9d37e75987e /Lib/test/test_xml_etree.py
parent3af1b5aefb9357a081e92b6f9752948b6cddae10 (diff)
downloadcpython-d9d578479613bd744b720f2b5d2ab6877cbfe508.tar.gz
Issue #12323: Strengthen error checking of the position XPath selectors
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r--Lib/test/test_xml_etree.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 00db44cdb7..def1b61810 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1793,6 +1793,11 @@ class ElementFindTest(unittest.TestCase):
self.assertEqual(e.find('./tag[last()-1]').attrib['class'], 'c')
self.assertEqual(e.find('./tag[last()-2]').attrib['class'], 'b')
+ self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[0]')
+ self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[-1]')
+ self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()-0]')
+ self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()+1]')
+
def test_findall(self):
e = ET.XML(SAMPLE_XML)
e[2] = ET.XML(SAMPLE_SECTION)