示例#1
0
文件: test.py 项目: rsbowman/AspectP
    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])
示例#2
0
文件: test.py 项目: rsbowman/AspectP
 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)