]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Minimal test for __del__ hook.
authorGuido van Rossum <guido@python.org>
Tue, 30 Oct 2001 02:33:02 +0000 (02:33 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 30 Oct 2001 02:33:02 +0000 (02:33 +0000)
Lib/test/test_descr.py

index e0c80ae8ca9c7b9abbab180d09c72839c01e898c..58c43167175240e3a4f5e871bf759a878d86033e 100644 (file)
@@ -2408,6 +2408,17 @@ def kwdargs():
     list.__init__(a, sequence=[0, 1, 2])
     vereq(a, [0, 1, 2])
 
+def delhook():
+    if verbose: print "Testing __del__ hook..."
+    log = []
+    class C(object):
+        def __del__(self):
+            log.append(1)
+    c = C()
+    vereq(log, [])
+    del c
+    vereq(log, [1])
+
 def test_main():
     class_docstrings()
     lists()
@@ -2459,6 +2470,7 @@ def test_main():
     buffer_inherit()
     str_of_str_subclass()
     kwdargs()
+    delhook()
     if verbose: print "All OK"
 
 if __name__ == "__main__":