File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -747,7 +747,9 @@ def __call__(self, **kwargs):
747
747
def call_historic (self , proc = None , kwargs = None ):
748
748
self ._call_history .append ((kwargs or {}, proc ))
749
749
# historizing hooks don't return results
750
- self ._hookexec (self , self ._nonwrappers + self ._wrappers , kwargs )
750
+ res = self ._hookexec (self , self ._nonwrappers + self ._wrappers , kwargs )
751
+ if res and proc is not None :
752
+ proc (res [0 ])
751
753
752
754
def call_extra (self , methods , kwargs ):
753
755
""" Call the hook with some additional temporarily participating
Original file line number Diff line number Diff line change @@ -212,6 +212,25 @@ def he_method1(self, arg):
212
212
pm .register (Plugin ())
213
213
assert l == [10 ]
214
214
215
+ def test_with_immediate_result_memorized (self , pm ):
216
+ class Hooks :
217
+ @hookspec (historic = True )
218
+ def he_method1 (self , arg ):
219
+ pass
220
+ pm .add_hookspecs (Hooks )
221
+
222
+ class Plugin :
223
+ @hookimpl
224
+ def he_method1 (self , arg ):
225
+ return arg * 10
226
+
227
+ l = []
228
+ pm .register (Plugin ())
229
+
230
+ he_method1 = pm .hook .he_method1
231
+ he_method1 .call_historic (lambda res : l .append (res ), dict (arg = 1 ))
232
+ assert l == [10 ]
233
+
215
234
def test_register_historic_incompat_hookwrapper (self , pm ):
216
235
class Hooks :
217
236
@hookspec (historic = True )
You can’t perform that action at this time.
0 commit comments