Skip to content

Commit

Permalink
Remove unnecessary gc_collect().
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Jan 24, 2024
1 parent 4a2d1d8 commit 3f5b365
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions Lib/test/test_xml_etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ def test_iterparse(self):
iterparse(SIMPLE_XMLFILE, events)
self.assertEqual(str(cm.exception), "unknown event 'bogus'")
del cm
gc_collect()

source = io.BytesIO(
b"<?xml version='1.0' encoding='iso-8859-1'?>\n"
Expand Down Expand Up @@ -653,34 +652,29 @@ def test_iterparse(self):
self.assertEqual(str(cm.exception),
'junk after document element: line 1, column 12')
del cm, it
gc_collect()

# Not exhausting the iterator still closes the resource (bpo-43292)
with warnings_helper.check_no_resource_warning(self):
it = iterparse(SIMPLE_XMLFILE)
del it
gc_collect()

with warnings_helper.check_no_resource_warning(self):
it = iterparse(SIMPLE_XMLFILE)
it.close()
del it
gc_collect()

with warnings_helper.check_no_resource_warning(self):
it = iterparse(SIMPLE_XMLFILE)
action, elem = next(it)
self.assertEqual((action, elem.tag), ('end', 'element'))
del it, elem
gc_collect()

with warnings_helper.check_no_resource_warning(self):
it = iterparse(SIMPLE_XMLFILE)
action, elem = next(it)
it.close()
self.assertEqual((action, elem.tag), ('end', 'element'))
del it, elem
gc_collect()

with self.assertRaises(FileNotFoundError):
iterparse("nonexistent")
Expand Down

0 comments on commit 3f5b365

Please sign in to comment.