

def testBaseHook(self):
    "make sure that the base class's hook is called reliably\n        "
    base = BaseClass()
    self.assertEquals(base.calledBase, 0)
    self.assertEquals(base.calledBasePre, 0)
    base.func(1, 2)
    self.assertEquals(base.calledBase, 1)
    self.assertEquals(base.calledBasePre, 0)
    hook.addPre(BaseClass, 'func', basePre)
    base.func(1, b=2)
    self.assertEquals(base.calledBase, 2)
    self.assertEquals(base.calledBasePre, 1)
    hook.addPost(BaseClass, 'func', basePost)
    base.func(1, b=2)
    self.assertEquals(base.calledBasePost, 1)
    self.assertEquals(base.calledBase, 3)
    self.assertEquals(base.calledBasePre, 2)
    hook.removePre(BaseClass, 'func', basePre)
    hook.removePost(BaseClass, 'func', basePost)
    base.func(1, b=2)
    self.assertEquals(base.calledBasePost, 1)
    self.assertEquals(base.calledBase, 4)
    self.assertEquals(base.calledBasePre, 2)

dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/test/test_hook.py HookTestCase.testBaseHook/original