示例#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)
示例#2
0
文件: utilsTests.py 项目: rexhsu/vdsm
 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)
示例#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])
示例#4
0
文件: utilsTests.py 项目: rexhsu/vdsm
 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])