def testReferences(self): #{{{
     '''Live reference (functions always alive)'''
     t1 = lambda: None
     class t2(object): #{{{
         def me(self): #{{{
             pass
         # End def #}}}
     # End class #}}}
     t3 = t2()
     cw = None
     for f in (t1, t2.me, t3.me):
         cw = CallableWrapper(f, weak=True)
         self.assertEqual(cw._isdead(), False)
     del t3, f
     self.assertTrue(cw._isdead())
Esempio n. 2
0
 def testDeadWrapper(self):  # {{{
     """Calling a dead wrapper generates a warning"""
     A = DummyClass
     a = A()
     w = CallableWrapper(a.DummyMethod)
     del a
     self.assert_(w._isdead())
 def testRemoveInstance(self): #{{{
     '''Deleting an instance makes for a dead CallableWrapper'''
     A = DummyClass
     a = A()
     w = CallableWrapper(a.DummyMethod)
     del a
     self.assert_(w._isdead())
    def testRemoveNonMethodCallable(self): #{{{
        '''Deleting a non-method callable makes for a dead CallableWrapper'''
        def DummyFunction(): #{{{
            return 'DummyFunction'
        # End def #}}}

        w = CallableWrapper(DummyFunction)
        del DummyFunction
        self.assert_(w._isdead())