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):
7272
7373 pm .add_hookspecs (Api )
7474
75- class Plugin (object ):
75+ class Plugin1 (object ):
7676 @hookimpl
7777 def hello (self , arg ):
7878 return arg + 1
7979
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
8193 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):
180180 assert not hasattr (he_myhook1 , name )
181181
182182
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-
201183def test_load_setuptools_instantiation (monkeypatch , pm ):
202184 pkg_resources = pytest .importorskip ("pkg_resources" )
203185
You can’t perform that action at this time.
0 commit comments