Example #1
0
    def testOrder(self):
        Foo = self.Foo
        a = self.Advice()
        pc = Call(Foo.baz)
        before(pc, a.append1)
        before(pc.copy(), a.append2)
        
        f = Foo()
        f.baz()

        self.assertEqual(a.events, [1, 2])
Example #2
0
 def testCall(self):
     Foo = self.Foo
     Boo = self.Boo
     pc = Call(Foo.bar)
     pc.setAdvice(lambda x: x)
     e = Event(Event.around, Foo(), Foo.baz, (), {})
     self.assertEqual(pc.isAdvisable(e), False)
     e = Event(Event.around, Foo(), Foo.bar, (), {})
     self.assertEqual(pc.isAdvisable(e), True)
     e = Event(Event.around, Boo(), Boo.bar, (), {})
     self.assertEqual(pc.isAdvisable(e), False)