def test_raise_on_invalid_weakref(self): obj = ObjectWithDel() method = utils.weakmethod(obj.public) obj.public = method self.assertEquals(obj.public(), ("public", (), {})) del obj self.assertRaises(utils.InvalidatedWeakRef, method)
def test_without_reference_cycle(self): obj = ObjectWithDel() obj.public = utils.weakmethod(obj.public) self.assertEquals(obj.public(), ("public", (), {})) del obj gc.collect() self.assertNotIn(ObjectWithDel, [type(obj) for obj in gc.garbage])