MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_findall_wildcard

Method test_findall_wildcard

Lib/test/test_xml_etree.py:3498–3540  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3496 self.assertEqual(len(root.findall(".//b", namespaces=nsmap)), 1)
3497
3498 def test_findall_wildcard(self):
3499 root = ET.XML('''
3500 <a xmlns:x="X" xmlns:y="Y">
3501 <x:b><c/></x:b>
3502 <b/>
3503 <c><x:b/><b/></c><y:b/>
3504 </a>''&#x27;)
3505 root.append(ET.Comment('test'))
3506
3507 self.assertEqual(summarize_list(root.findall("{*}b")),
3508 ['{X}b', 'b', '{Y}b'])
3509 self.assertEqual(summarize_list(root.findall("{*}c")),
3510 ['c'])
3511 self.assertEqual(summarize_list(root.findall("{X}*")),
3512 ['{X}b'])
3513 self.assertEqual(summarize_list(root.findall("{Y}*")),
3514 ['{Y}b'])
3515 self.assertEqual(summarize_list(root.findall("{}*")),
3516 ['b', 'c'])
3517 self.assertEqual(summarize_list(root.findall("{}b")), # only for consistency
3518 ['b'])
3519 self.assertEqual(summarize_list(root.findall("{}b")),
3520 summarize_list(root.findall("b")))
3521 self.assertEqual(summarize_list(root.findall("{*}*")),
3522 ['{X}b', 'b', 'c', '{Y}b'])
3523 # This is an unfortunate difference, but that's how find('*') works.
3524 self.assertEqual(summarize_list(root.findall("{*}*") + [root[-1]]),
3525 summarize_list(root.findall("*")))
3526
3527 self.assertEqual(summarize_list(root.findall(".//{*}b")),
3528 ['{X}b', 'b', '{X}b', 'b', '{Y}b'])
3529 self.assertEqual(summarize_list(root.findall(".//{*}c")),
3530 ['c', 'c'])
3531 self.assertEqual(summarize_list(root.findall(".//{X}*")),
3532 ['{X}b', '{X}b'])
3533 self.assertEqual(summarize_list(root.findall(".//{Y}*")),
3534 ['{Y}b'])
3535 self.assertEqual(summarize_list(root.findall(".//{}*")),
3536 ['c', 'b', 'c', 'b'])
3537 self.assertEqual(summarize_list(root.findall(".//{}b")), # only for consistency
3538 ['b', 'b'])
3539 self.assertEqual(summarize_list(root.findall(".//{}b")),
3540 summarize_list(root.findall(".//b")))
3541
3542 def test_bad_find(self):
3543 e = ET.XML(SAMPLE_XML)

Callers

nothing calls this directly

Calls 4

summarize_listFunction · 0.85
appendMethod · 0.45
assertEqualMethod · 0.45
findallMethod · 0.45

Tested by

no test coverage detected