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

Method test_refleak

Lib/test/test_optparse.py:400–414  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

398
399 @support.impl_detail('Relies on sys.getrefcount', cpython=True)
400 def test_refleak(self):
401 # If an OptionParser is carrying around a reference to a large
402 # object, various cycles can prevent it from being GC'd in
403 # a timely fashion. destroy() breaks the cycles to ensure stuff
404 # can be cleaned up.
405 big_thing = [42]
406 refcount = sys.getrefcount(big_thing)
407 parser = OptionParser()
408 parser.add_option("-a", "--aaarggh")
409 parser.big_thing = big_thing
410
411 parser.destroy()
412 #self.assertEqual(refcount, sys.getrefcount(big_thing))
413 del parser
414 self.assertEqual(refcount, sys.getrefcount(big_thing))
415
416
417class TestOptionValues(BaseTest):

Callers

nothing calls this directly

Calls 4

destroyMethod · 0.95
OptionParserClass · 0.90
add_optionMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected