Skip to content

Commit d92ae84

Browse files
committed
test_saveall(): Another small simplification; plus s/l/L/g.
test_del(), test_del_newclass(): No need to use apply() in these.
1 parent a1ad3f0 commit d92ae84

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

Lib/test/test_gc.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,19 @@ def test_saveall():
174174
gc.collect()
175175
vereq(gc.garbage, []) # if this fails, someone else created immortal trash
176176

177-
l = []
178-
l.append(l)
179-
id_l = id(l)
177+
L = []
178+
L.append(L)
179+
id_L = id(L)
180180

181181
debug = gc.get_debug()
182182
gc.set_debug(debug | gc.DEBUG_SAVEALL)
183-
del l
183+
del L
184184
gc.collect()
185185
gc.set_debug(debug)
186186

187187
vereq(len(gc.garbage), 1)
188-
if id(gc.garbage[0]) == id_l:
189-
del gc.garbage[0]
190-
else:
191-
raise TestFailed, "didn't find obj in garbage (saveall)"
188+
obj = gc.garbage.pop()
189+
vereq(id(obj), id_L)
192190

193191
def test_del():
194192
# __del__ methods can trigger collection, make this to happen
@@ -203,7 +201,7 @@ def __del__(self):
203201
del a
204202

205203
gc.disable()
206-
apply(gc.set_threshold, thresholds)
204+
gc.set_threshold(*thresholds)
207205

208206
def test_del_newclass():
209207
# __del__ methods can trigger collection, make this to happen
@@ -218,7 +216,7 @@ def __del__(self):
218216
del a
219217

220218
gc.disable()
221-
apply(gc.set_threshold, thresholds)
219+
gc.set_threshold(*thresholds)
222220

223221
class Ouch:
224222
n = 0

0 commit comments

Comments
 (0)