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: Creates 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 object obj: An object.
  :param unicode name: A method in object.
  :rtype: mock.MagicMock
  :return: Spy object.
docstr_tok: ["Creates","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","object","obj",":","An","object",".",":","param","unicode","name",":","A","method","in","object",".",":","rtype",":","mock.MagicMock",":","return",":","Spy","object","."]
code: def spy(self, obj, name):
      """
      Creates 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 object obj: An object.
      :param unicode name: A method in object.
      :rtype: mock.MagicMock
      :return: Spy object.
      """
      method = getattr(obj, name)
  
      autospec = inspect.ismethod(method) or inspect.isfunction(method)
      # Can't use autospec classmethod or staticmethod objects
      # see: https://bugs.python.org/issue23078
      if inspect.isclass(obj):
          # Bypass class descriptor:
          # http://stackoverflow.com/questions/14187973/python3-check-if-method-is-static
          try:
              value = obj.__getattribute__(obj, name)
          except AttributeError:
              pass
          else:
              if isinstance(value, (classmethod, staticmethod)):
                  autospec = False
  
      if sys.version_info[0] == 2:
          assigned = [
              x
              for x in functools.WRAPPER_ASSIGNMENTS
              if hasattr(method, x)
          ]
          w = functools.wraps(method, assigned=assigned)
      else:
          w = functools.wraps(method)
  
      @w
      def wrapper(*args, **kwargs):
          spy_obj.spy_return = None
          spy_obj.spy_exception = None
          try:
              r = method(*args, **kwargs)
          except Exception as e:
              spy_obj.spy_exception = e
              raise
          else:
              spy_obj.spy_return = r
          return r
  
      spy_obj = self.patch.object(
          obj, name, side_effect=wrapper, autospec=autospec
      )
      spy_obj.spy_return = None
      spy_obj.spy_exception = None
      return spy_obj
  
imports: from __future__ import unicode_literals
  import functools
  import inspect
  import sys
  import pytest
  import six
  from ._version import version
label_desc: Use image node_id 4 for calling the MockFixture obj's underlying member method code with example usage: obj.spy(obj, name) and returns: spy_obj, r