Skip to content

Commit 84fb9ea

Browse files
author
Tyler Goodlet
committed
Add a plugin call-order test
1 parent b1b9de2 commit 84fb9ea

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

testing/test_hookrelay.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,44 @@ def hello(self, arg):
6464
assert comprehensible in str(exc.value)
6565

6666

67+
def test_call_order(pm):
68+
class Api(object):
69+
@hookspec
70+
def hello(self, arg):
71+
"api hook 1"
72+
73+
pm.add_hookspecs(Api)
74+
75+
class Plugin1(object):
76+
@hookimpl
77+
def hello(self, arg):
78+
return 1
79+
80+
class Plugin2(object):
81+
@hookimpl
82+
def hello(self, arg):
83+
return 2
84+
85+
class Plugin3(object):
86+
@hookimpl
87+
def hello(self, arg):
88+
return 3
89+
90+
class Plugin4(object):
91+
@hookimpl(hookwrapper=True)
92+
def hello(self, arg):
93+
assert arg == 0
94+
outcome = yield
95+
assert outcome.get_result() == [3, 2, 1]
96+
97+
pm.register(Plugin1())
98+
pm.register(Plugin2())
99+
pm.register(Plugin3())
100+
pm.register(Plugin4()) # hookwrapper should get same list result
101+
res = pm.hook.hello(arg=0)
102+
assert res == [3, 2, 1]
103+
104+
67105
def test_firstresult_definition(pm):
68106
class Api(object):
69107
@hookspec(firstresult=True)

0 commit comments

Comments
 (0)