mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-30485: support a default prefix mapping in ElementPath by passing None as prefix (#1823)
This commit is contained in:
parent
ffca16e25a
commit
e9927e1820
4 changed files with 39 additions and 12 deletions
|
|
@ -2463,6 +2463,12 @@ class ElementFindTest(unittest.TestCase):
|
|||
nsmap = {'xx': 'Y'}
|
||||
self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 1)
|
||||
self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 2)
|
||||
nsmap = {'xx': 'X', None: 'Y'}
|
||||
self.assertEqual(len(root.findall(".//xx:b", namespaces=nsmap)), 2)
|
||||
self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 1)
|
||||
nsmap = {'xx': 'X', '': 'Y'}
|
||||
with self.assertRaisesRegex(ValueError, 'namespace prefix'):
|
||||
root.findall(".//xx:b", namespaces=nsmap)
|
||||
|
||||
def test_bad_find(self):
|
||||
e = ET.XML(SAMPLE_XML)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue