code: def test_with_result_memorized(
      pm: PluginManager, result_callback: bool
  ) -> None:
      """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 not result_callback:
          callback = None
      else:
  
          def callback(res) -> None:
              out.append(res)
  
      class Hooks:
          @hookspec(historic=True)
          def he_method1(self, arg):
              pass
  
      pm.add_hookspecs(Hooks)
  
      class Plugin1:
          @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:
          @hookimpl
          def he_method1(self, arg):
              return arg * 10
  
      pm.register(Plugin2())
      if result_callback:
          assert out == [10, 10]
      else:
          assert out == []
  
imports: import sys
  from typing import Any
  from typing import List
  import pytest
  from pluggy import HookCallError
  from pluggy import HookimplMarker
  from pluggy import HookspecMarker
  from pluggy import PluginManager
  from pluggy import PluginValidationError
label_desc: Use image node_id 15 for calling a global function with example usage: test_with_result_memorized(pm, result_callback) and returns: unknown, unknown