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