import gc

import pygtk
pygtk.require('2.0')

import gobject
import gtk

  
class TestCycle(gtk.EventBox):
  """ Subclass of button that allows icon to be set.  """
  
  def __init__(self):

    gtk.EventBox.__init__(self)
    self.connect('notify', self.cb)
    class DetectDel:
      def __del__(self):
        print 'del'
    self.d = DetectDel()

  def cb(self, *args):
    pass

def test():
        print gobject
        a = TestCycle()
        a.foo = 1
        b = gtk.EventBox()
        b.add(a)
        print id(a)
        
        del a

        while gc.collect():
            pass
        a = b.child
        print id(a)
        assert a.foo == 1
test()