summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmox.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/mox.py b/mox.py
index b2c671f..fce84bb 100755
--- a/mox.py
+++ b/mox.py
@@ -807,20 +807,28 @@ class MockObject(MockAnything):
return mock_method(*params, **named_params)
@property
- def __class__(self):
- """Return the class that is being mocked."""
-
- return self._class_to_mock
-
- @property
def __name__(self):
"""Return the name that is being mocked."""
return self._description
+ # TODO(dejw): this property stopped to work after I introduced changes with
+ # binding classes. Fortunately I found a solution in the form of
+ # __getattribute__ method below, but this issue should be investigated
+ @property
+ def __class__(self):
+ return self._class_to_mock
+
def __dir__(self):
"""Return only attributes of a class to mock """
return dir(self._class_to_mock)
+ def __getattribute__(self, name):
+ """Return _class_to_mock on __class__ attribute. """
+ if name == "__class__":
+ return super(MockObject, self).__getattribute__("_class_to_mock")
+
+ return super(MockObject, self).__getattribute__(name)
+
class _MockObjectFactory(MockObject):
"""A MockObjectFactory creates mocks and verifies __init__ params.