class_docstr: Fixture that provides the same interface to functions in the mock module,
  ensuring that they are uninstalled at the end of each test.
class_docstr_tok: ["Fixture","that","provides","the","same","interface","to","functions","in","the","mock","module",",","ensuring","that","they","are","uninstalled","at","the","end","of","each","test","."]
docstr: Create a spy of method. It will run method normally, but it is now
  possible to use `mock` call features with it, like call count.
  
  :param obj: An object.
  :param name: A method in object.
  :return: Spy object.
code: def spy(self, obj: object, name: str) -> MockType:
      """
      Create a spy of method. It will run method normally, but it is now
      possible to use `mock` call features with it, like call count.
  
      :param obj: An object.
      :param name: A method in object.
      :return: Spy object.
      """
      method = getattr(obj, name)
      if inspect.isclass(obj) and isinstance(
          inspect.getattr_static(obj, name), (classmethod, staticmethod)
      ):
          # Can't use autospec classmethod or staticmethod objects before 3.7
          # see: https://bugs.python.org/issue23078
          autospec = False
      else:
          autospec = inspect.ismethod(method) or inspect.isfunction(
              method
          )
  
      def wrapper(*args, **kwargs):
          spy_obj.spy_return = None
          spy_obj.spy_exception = None
          try:
              r = method(*args, **kwargs)
          except BaseException as e:
              spy_obj.spy_exception = e
              raise
          else:
              spy_obj.spy_return = r
          return r
  
      async def async_wrapper(*args, **kwargs):
          spy_obj.spy_return = None
          spy_obj.spy_exception = None
          try:
              r = await method(*args, **kwargs)
          except BaseException as e:
              spy_obj.spy_exception = e
              raise
          else:
              spy_obj.spy_return = r
          return r
  
      if asyncio.iscoroutinefunction(method):
          wrapped = functools.update_wrapper(async_wrapper, method)
      else:
          wrapped = functools.update_wrapper(wrapper, method)
  
      spy_obj = self.patch.object(
          obj, name, side_effect=wrapped, autospec=autospec
      )
      spy_obj.spy_return = None
      spy_obj.spy_exception = None
      return spy_obj
  
imports: import asyncio
  import builtins
  import functools
  import inspect
  import sys
  import unittest.mock
  import warnings
  from typing import Any
  from typing import Callable
  from typing import cast
  from typing import Dict
  from typing import Generator
  from typing import Iterable
  from typing import List
  from typing import Mapping
  from typing import Optional
  from typing import overload
  from typing import Tuple
  from typing import Type
  from typing import TypeVar
  from typing import Union
  import pytest
  from ._util import get_mock_module
  from ._util import parse_ini_boolean
label_desc: Use image node_id 6 for calling the MockerFixture obj's underlying member method code with example usage: obj.spy(obj, name) and returns: spy_obj, r, r