MCPcopy Index your code
hub / github.com/python/cpython / test_element_factory

Method test_element_factory

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

Source from the content-addressed store, hash-verified

3860 self._check_sample1_element(e)
3861
3862 def test_element_factory(self):
3863 lst = []
3864 def myfactory(tag, attrib):
3865 nonlocal lst
3866 lst.append(tag)
3867 return ET.Element(tag, attrib)
3868
3869 tb = ET.TreeBuilder(element_factory=myfactory)
3870 parser = ET.XMLParser(target=tb)
3871 parser.feed(self.sample2)
3872 parser.close()
3873
3874 self.assertEqual(lst, ['toplevel'])
3875
3876 def _check_element_factory_class(self, cls):
3877 tb = ET.TreeBuilder(element_factory=cls)

Callers

nothing calls this directly

Calls 3

feedMethod · 0.95
closeMethod · 0.95
assertEqualMethod · 0.45

Tested by

no test coverage detected