(lst)
| 2000 | exc.append(ex) |
| 2001 | |
| 2002 | def pop_and_collect(lst): |
| 2003 | gc_ctr = 0 |
| 2004 | while lst: |
| 2005 | i = random.randint(0, len(lst) - 1) |
| 2006 | gc_ctr += 1 |
| 2007 | lst.pop(i) |
| 2008 | if gc_ctr % 10000 == 0: |
| 2009 | gc.collect() # just in case |
| 2010 | |
| 2011 | self.assertIn(type_, (weakref.WeakKeyDictionary, weakref.WeakValueDictionary)) |
| 2012 |