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

Method test_lost_elem

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

Source from the content-addressed store, hash-verified

2522 self.assertEqual(e[0].tail, 'changed')
2523
2524 def test_lost_elem(self):
2525 # Issue #25902: Borrowed element can disappear
2526 class Tag:
2527 def __eq__(self, other):
2528 e[0] = ET.Element('changed')
2529 next(i)
2530 return True
2531
2532 e = ET.Element('root')
2533 e.append(ET.Element(Tag()))
2534 e.append(ET.Element('tag'))
2535 i = e.iter('tag')
2536 try:
2537 t = next(i)
2538 except ValueError:
2539 self.skipTest('generators are not reentrant')
2540 self.assertIsInstance(t.tag, Tag)
2541 self.assertIsInstance(e[0].tag, str)
2542 self.assertEqual(e[0].tag, 'changed')
2543
2544 def check_expat224_utf8_bug(self, text):
2545 xml = b'<a b="%s"/>' % text

Callers

nothing calls this directly

Calls 6

appendMethod · 0.95
iterMethod · 0.95
TagClass · 0.85
skipTestMethod · 0.80
assertIsInstanceMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected