]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
test_saveall(): Simplified a little, given that we only expect one item
authorTim Peters <tim.peters@gmail.com>
Sat, 10 Aug 2002 21:29:56 +0000 (21:29 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 10 Aug 2002 21:29:56 +0000 (21:29 +0000)
in gc.garbage (so no need to loop looking for it -- it's there or it's
not).

Lib/test/test_gc.py

index 46448badd1bc59cf560038fb1020c70fe30eeedd..2e1bc11ab94b4f7e0dffc2cd092bbb9ca5e3d915 100644 (file)
@@ -180,16 +180,14 @@ def test_saveall():
     l.append(l)
     id_l = id(l)
     del l
+
     gc.collect()
-    vereq(len(gc.garbage), 1)
     try:
-        for obj in gc.garbage:
-            if id(obj) == id_l:
-                del obj[:]
-                break
+        vereq(len(gc.garbage), 1)
+        if id(gc.garbage[0]) == id_l:
+            del gc.garbage[0]
         else:
             raise TestFailed, "didn't find obj in garbage (saveall)"
-        gc.garbage.remove(obj)
     finally:
         gc.set_debug(debug)