def test_floating_and_sunk_out_of_scope_using_gobject_new(self): obj = GObject.new(testhelper.FloatingAndSunk) self.assertEqual(obj.__grefcount__, 2) # We are manually taking the object out of scope. This means # that our wrapper has been freed, and its reference dropped. We # cannot check it but the refcount should now be 1 (the ref held # by the library is still there, we didn't call release() obj = None # When we get the object back from the lib, the wrapper is # re-created, so our refcount will be 2 once again. obj = testhelper.floating_and_sunk_get_instance_list()[0] self.assertEqual(obj.__grefcount__, 2) obj.release() self.assertEqual(obj.__grefcount__, 1)
def test_floating_and_sunk_out_of_scope_using_gobject_new(self): obj = GObject.new(testhelper.FloatingAndSunk) self.assertEqual(obj.__grefcount__, 2) # We are manually taking the object out of scope. This means # that our wrapper has been freed, and its reference dropped. We # cannot check it but the refcount should now be 1 (the ref held # by the library is still there, we didn't call release() obj = None # When we get the object back from the lib, the wrapper is # re-created, so our refcount will be 2 once again. obj = testhelper.floating_and_sunk_get_instance_list()[0] self.assertEqual(obj.__grefcount__, 2) obj.release() self.assertEqual(obj.__grefcount__, 1)