예제 #1
0
    class B:
        before = InstanceHook()
        after = InstanceHook()

        @after
        @before
        def greeting(self, name):
            return 'Hello {}'.format(name)
예제 #2
0
    class B(Hookable):
        before = InstanceHook()

        @before
        def on_before1(self):
            assert isinstance(self, B)
            return 1
예제 #3
0
파일: test_hook.py 프로젝트: jonike/hookery
    class B:
        before = InstanceHook(consume_generators=False)

        @before
        def generate_some(self):
            yield from range(3)

        @before
        def generate_more(self):
            yield from range(2)
예제 #4
0
파일: test_hook.py 프로젝트: jonike/hookery
    class B:
        before = InstanceHook()
        after = ClassHook()

        @before
        def on_before(self, x):
            assert isinstance(self, B)
            return x * 3

        @after
        def on_after(cls, y):
            assert cls is B
            return y * 5
예제 #5
0
파일: test_hook.py 프로젝트: jonike/hookery
    class C(B):
        between = InstanceHook()
        betwixt = ClassHook()

        @between
        def on_between(self, x):
            assert isinstance(self, C)
            return x * 4

        @betwixt
        def on_betwixt(cls, y):
            assert cls is C
            return y * 6
예제 #6
0
    class Base(Hookable):
        before = InstanceHook()

        before(lambda: 1)
예제 #7
0
 class Base(Hookable):
     before = InstanceHook()
예제 #8
0
class Address:
    updated = InstanceHook()

    city = ObservableAttr('city')
    country = ObservableAttr('country')
예제 #9
0
 class Field:
     parser = InstanceHook(single_handler=True)
예제 #10
0
 class C:
     before = InstanceHook()
예제 #11
0
def test_standalone_initialisation():
    before = InstanceHook('before')
    assert isinstance(before, InstanceHook)
    assert before.name == 'before'
예제 #12
0
 class Derived(Base):
     after = InstanceHook()
예제 #13
0
 class Base:
     before = InstanceHook()
예제 #14
0
파일: test_hook.py 프로젝트: jonike/hookery
 class C(B):
     before = InstanceHook()  # overwrite, has no connection B.before
예제 #15
0
 class B:
     before = InstanceHook()
예제 #16
0
 class B:
     before = InstanceHook()
     after = InstanceHook()
예제 #17
0
 class C:
     before = InstanceHook(args=['x', 'y'])