From: Guido van Rossum Date: Tue, 30 Oct 2001 02:33:02 +0000 (+0000) Subject: Minimal test for __del__ hook. X-Git-Tag: v2.2.1c1~968 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed87ad876bf195b22d08eefb9328e548a30f8795;p=thirdparty%2FPython%2Fcpython.git Minimal test for __del__ hook. --- diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index e0c80ae8ca9c..58c431671752 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -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__":