def __init__(self, class_to_mock, attrs={}):
    """Initialize a mock object.

    This determines the methods and properties of the class and stores them.

    Args:
      # class_to_mock: class to be mocked
      class_to_mock: class
      attrs: dict of attribute names to values that will be set on the mock
        object.  Only public attributes may be set.

    Raises:
      PrivateAttributeError: if a supplied attribute is not public.
      ValueError: if an attribute would mask an existing method.
    """

    # This is used to hack around the mixin/inheritance of MockAnything, which
    # is not a proper object (it can be anything. :-)
    MockAnything.__dict__['__init__'](self)

    # Get a list of all the public and special methods we should mock.
    self._known_methods = set()
    self._known_vars = set()
    self._class_to_mock = class_to_mock
    try:
      self._description = class_to_mock.__name__
      # If class_to_mock is a mock itself, then we'll get an UnknownMethodCall
      # error here from the underlying call to __getattr__('__name__')
    except (UnknownMethodCallError, AttributeError):
      try:
        self._description = type(class_to_mock).__name__
      except AttributeError:
        pass

    for method in dir(class_to_mock):
      attr = getattr(class_to_mock, method)
      if callable(attr):
        self._known_methods.add(method)
      elif not (type(attr) is property):
        # treating properties as class vars makes little sense.
        self._known_vars.add(method)

    # Set additional attributes at instantiation time; this is quicker
    # than manually setting attributes that are normally created in
    # __init__.
    for attr, value in attrs.items():
      if attr.startswith("_"):
        raise PrivateAttributeError(attr)
      elif attr in self._known_methods:
        raise ValueError("'%s' is a method of '%s' objects." % (attr,
                                                                class_to_mock))
      else:
        setattr(self, attr, value)
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/mox/mox.py/MockObject.__init__/original