Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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])
Example #4
0
 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])