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

Method test_late_tail

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

Source from the content-addressed store, hash-verified

3765 self.assertEqual(b.pi('pitarget', ' text '), (len('pitarget'), ' text '))
3766
3767 def test_late_tail(self):
3768 # Issue #37399: The tail of an ignored comment could overwrite the text before it.
3769 class TreeBuilderSubclass(ET.TreeBuilder):
3770 pass
3771
3772 xml = "<a>text<!-- comment -->tail</a>"
3773 a = ET.fromstring(xml)
3774 self.assertEqual(a.text, "texttail")
3775
3776 parser = ET.XMLParser(target=TreeBuilderSubclass())
3777 parser.feed(xml)
3778 a = parser.close()
3779 self.assertEqual(a.text, "texttail")
3780
3781 xml = "<a>text<?pi data?>tail</a>"
3782 a = ET.fromstring(xml)
3783 self.assertEqual(a.text, "texttail")
3784
3785 xml = "<a>text<?pi data?>tail</a>"
3786 parser = ET.XMLParser(target=TreeBuilderSubclass())
3787 parser.feed(xml)
3788 a = parser.close()
3789 self.assertEqual(a.text, "texttail")
3790
3791 def test_late_tail_mix_pi_comments(self):
3792 # Issue #37399: The tail of an ignored comment could overwrite the text before it.

Callers

nothing calls this directly

Calls 5

feedMethod · 0.95
closeMethod · 0.95
TreeBuilderSubclassClass · 0.85
fromstringMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected