test_00_PythonUtils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def test_WeakObject(self):
        """
        Tests basic extended weak object support.
        """
        obj = TestClass()
        ref = weakref.ref(obj)

        objref = weakobj.objectref(obj)
        objref2 = weakobj.objectref(obj)

        self.assertEquals(objref, objref2)
        self.assertEquals(objref.foo(), obj.foo())

        # Delete what should be the only reference to the original object.
        del obj
        self.assertEqual(ref(), None)

        try:
            objref.foo()
        except weakref.ReferenceError:
            pass
        else:
            self.fail('Weak object should be invalidated')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号