def test_finalizer():
 global val, called
 val = None
 called = False
 class X(object, ):
  def __new__(cls):
   global val
   if (val == None):
    val = object.__new__(cls)
   return val
  def __del__(self):
   called = True
 a = X()
 b = X()
 AreEqual(id(a), id(b))
 import gc
 gc.collect()
 AreEqual(called, False)

def test_finalizer ( ) : global val , called val = None called = False class X ( object , ) : def __new__ ( cls ) : global val if ( val == None ) : val = object . __new__ ( cls ) return val def __del__ ( self ) : called = True a = X ( ) b = X ( ) AreEqual ( id ( a ) , id ( b ) ) import gc gc . collect ( ) AreEqual ( called , False )
returning the same object from __new__ shouldnt cause it to be finalized .