bpo-30485: support a default prefix mapping in ElementPath by passing None as prefix (#1823)

This commit is contained in:
Stefan Behnel 2019-04-14 10:09:09 +02:00 committed by GitHub
parent ffca16e25a
commit e9927e1820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 12 deletions

View file

@ -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)