test_saveall(): Another small simplification; plus s/l/L/g.

test_del(), test_del_newclass():  No need to use apply() in these.
This commit is contained in:
Tim Peters 2002-08-11 04:15:09 +00:00
parent a1ad3f08ad
commit d92ae840e9

View file

@ -174,21 +174,19 @@ def test_saveall():
gc.collect() gc.collect()
vereq(gc.garbage, []) # if this fails, someone else created immortal trash vereq(gc.garbage, []) # if this fails, someone else created immortal trash
l = [] L = []
l.append(l) L.append(L)
id_l = id(l) id_L = id(L)
debug = gc.get_debug() debug = gc.get_debug()
gc.set_debug(debug | gc.DEBUG_SAVEALL) gc.set_debug(debug | gc.DEBUG_SAVEALL)
del l del L
gc.collect() gc.collect()
gc.set_debug(debug) gc.set_debug(debug)
vereq(len(gc.garbage), 1) vereq(len(gc.garbage), 1)
if id(gc.garbage[0]) == id_l: obj = gc.garbage.pop()
del gc.garbage[0] vereq(id(obj), id_L)
else:
raise TestFailed, "didn't find obj in garbage (saveall)"
def test_del(): def test_del():
# __del__ methods can trigger collection, make this to happen # __del__ methods can trigger collection, make this to happen
@ -203,7 +201,7 @@ def test_del():
del a del a
gc.disable() gc.disable()
apply(gc.set_threshold, thresholds) gc.set_threshold(*thresholds)
def test_del_newclass(): def test_del_newclass():
# __del__ methods can trigger collection, make this to happen # __del__ methods can trigger collection, make this to happen
@ -218,7 +216,7 @@ def test_del_newclass():
del a del a
gc.disable() gc.disable()
apply(gc.set_threshold, thresholds) gc.set_threshold(*thresholds)
class Ouch: class Ouch:
n = 0 n = 0