code: def test_with_result_memorized(pm, result_callback):
      """Verify that ``_HookCaller._maybe_apply_history()`
      correctly applies the ``result_callback`` function, when provided,
      to the result from calling each newly registered hook.
      """
      out = []
      if result_callback:
  
          def callback(res):
              out.append(res)
  
      else:
          callback = None
  
      class Hooks(object):
          @hookspec(historic=True)
          def he_method1(self, arg):
              pass
  
      pm.add_hookspecs(Hooks)
  
      class Plugin1(object):
          @hookimpl
          def he_method1(self, arg):
              return arg * 10
  
      pm.register(Plugin1())
  
      he_method1 = pm.hook.he_method1
      he_method1.call_historic(
          result_callback=callback, kwargs=dict(arg=1)
      )
  
      class Plugin2(object):
          @hookimpl
          def he_method1(self, arg):
              return arg * 10
  
      pm.register(Plugin2())
      if result_callback:
          assert out == [10, 10]
      else:
          assert out == []
  
imports: import pytest
  import types
  from pluggy import PluginManager, PluginValidationError, HookCallError, HookimplMarker, HookspecMarker
  from pluggy.manager import importlib_metadata
label_desc: Use image node_id 12 for calling a global function with example usage: test_with_result_memorized(pm, result_callback) and returns: unknown, unknown