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

Method test_cyclic_gc

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

Source from the content-addressed store, hash-verified

2674
2675 @unittest.expectedFailure # TODO: RUSTPYTHON
2676 def test_cyclic_gc(self):
2677 class Dummy:
2678 pass
2679
2680 # Test the shortest cycle: d->element->d
2681 d = Dummy()
2682 d.dummyref = ET.Element('joe', attr=d)
2683 wref = weakref.ref(d)
2684 del d
2685 gc_collect()
2686 self.assertIsNone(wref())
2687
2688 # A longer cycle: d->e->e2->d
2689 e = ET.Element('joe')
2690 d = Dummy()
2691 d.dummyref = e
2692 wref = weakref.ref(d)
2693 e2 = ET.SubElement(e, 'foo', attr=d)
2694 del d, e, e2
2695 gc_collect()
2696 self.assertIsNone(wref())
2697
2698 # A cycle between Element objects as children of one another
2699 # e1->e2->e3->e1
2700 e1 = ET.Element('e1')
2701 e2 = ET.Element('e2')
2702 e3 = ET.Element('e3')
2703 e3.append(e1)
2704 e2.append(e3)
2705 e1.append(e2)
2706 wref = weakref.ref(e1)
2707 del e1, e2, e3
2708 gc_collect()
2709 self.assertIsNone(wref())
2710
2711 def test_weakref(self):
2712 flag = False

Callers

nothing calls this directly

Calls 4

appendMethod · 0.95
gc_collectFunction · 0.90
assertIsNoneMethod · 0.80
DummyClass · 0.70

Tested by

no test coverage detected