File tree Expand file tree Collapse file tree 2 files changed +15
-21
lines changed Expand file tree Collapse file tree 2 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,23 @@ def hello(self, arg):
72
72
73
73
pm .add_hookspecs (Api )
74
74
75
- class Plugin (object ):
75
+ class Plugin1 (object ):
76
76
@hookimpl
77
77
def hello (self , arg ):
78
78
return arg + 1
79
79
80
- pm .register (Plugin ())
80
+ class Plugin2 (object ):
81
+ @hookimpl
82
+ def hello (self , arg ):
83
+ return arg - 1
84
+
85
+ class Plugin3 (object ):
86
+ @hookimpl
87
+ def hello (self , arg ):
88
+ return None
89
+
90
+ pm .register (Plugin1 ()) # discarded - not the last registered plugin
91
+ pm .register (Plugin2 ()) # used as result
92
+ pm .register (Plugin3 ()) # None result is ignored
81
93
res = pm .hook .hello (arg = 3 )
82
- assert res == 4
94
+ assert res == 2
Original file line number Diff line number Diff line change @@ -180,24 +180,6 @@ def he_myhook1(arg1):
180
180
assert not hasattr (he_myhook1 , name )
181
181
182
182
183
- def test_decorator_functional (pm ):
184
- class HookSpec (object ):
185
- @hookspec (firstresult = True )
186
- def he_myhook (self , arg1 ):
187
- """ add to arg1 """
188
-
189
- pm .add_hookspecs (HookSpec )
190
-
191
- class Plugin (object ):
192
- @hookimpl ()
193
- def he_myhook (self , arg1 ):
194
- return arg1 + 1
195
-
196
- pm .register (Plugin ())
197
- results = pm .hook .he_myhook (arg1 = 17 )
198
- assert results == 18
199
-
200
-
201
183
def test_load_setuptools_instantiation (monkeypatch , pm ):
202
184
pkg_resources = pytest .importorskip ("pkg_resources" )
203
185
You can’t perform that action at this time.
0 commit comments