mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Merge fix for Issue #17011 from 3.3
This commit is contained in:
commit
b9b6ce6f2c
2 changed files with 18 additions and 2 deletions
|
@ -1839,6 +1839,20 @@ class ElementFindTest(unittest.TestCase):
|
|||
summarize_list(e.findall(".//{http://effbot.org/ns}tag")),
|
||||
['{http://effbot.org/ns}tag'] * 3)
|
||||
|
||||
def test_findall_different_nsmaps(self):
|
||||
root = ET.XML('''
|
||||
<a xmlns:x="X" xmlns:y="Y">
|
||||
<x:b><c/></x:b>
|
||||
<b/>
|
||||
<c><x:b/><b/></c><y:b/>
|
||||
</a>''')
|
||||
nsmap = {'xx': 'X'}
|
||||
self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 2)
|
||||
self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2)
|
||||
nsmap = {'xx': 'Y'}
|
||||
self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 1)
|
||||
self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2)
|
||||
|
||||
def test_bad_find(self):
|
||||
e = ET.XML(SAMPLE_XML)
|
||||
with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue