def test_element_cyclic_gc_none(self):
# test if cyclic reference can crash etree
Element = self.etree.Element
# must disable tracing as it could change the refcounts
trace_func = sys.gettrace()
try:
sys.settrace(None)
gc.collect()
count = sys.getrefcount(None)
l = [Element('name'), Element('name')]
l.append(l)
del l
gc.collect()
self.assertEqual(sys.getrefcount(None), count)
finally:
sys.settrace(trace_func)
评论列表
文章目录