Normally the __class__ attribute of an object will return its type. For a mock object with a spec, __class__ returns the spec class instead. This allows mock objects to pass isinstance() tests for the object they are replacing / masquerading as:
>>> mock = Mock() >>> mock.__class__ = dict >>> isinstance(mock, dict) True
unittest.mock/Mock.__class__
Mock.__class__