]> granicus.if.org Git - python/commitdiff
Add a testcase to ensure that cycles going through the __class__ link
authorGuido van Rossum <guido@python.org>
Wed, 12 Jun 2002 14:38:04 +0000 (14:38 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 12 Jun 2002 14:38:04 +0000 (14:38 +0000)
of a new-style instance are detected by the garbage collector.

Lib/test/test_gc.py

index 22f7e74114be79617b6ebebd3f46c6f3b3bc8879..23bb7c5cc9eb5409dad0194d157288ed21a3bca4 100644 (file)
@@ -83,6 +83,12 @@ def test_newinstance():
     gc.collect()
     del a
     expect_nonzero(gc.collect(), "newinstance(2)")
+    del B, C
+    expect_nonzero(gc.collect(), "newinstance(3)")
+    A.a = A()
+    del A
+    expect_nonzero(gc.collect(), "newinstance(4)")
+    expect(gc.collect(), 0, "newinstance(5)")
 
 def test_method():
     # Tricky: self.__init__ is a bound method, it references the instance.