summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Fatyga <dawid.fatyga@gmail.com>2012-04-24 22:53:00 +0200
committerDawid Fatyga <dawid.fatyga@gmail.com>2012-04-24 22:53:00 +0200
commit09fd9fa35368f98c33199eccb41e6d9bfe4c84c4 (patch)
tree3a9f5760e0457ebdecdf03eeb7970af201e1ad46
parent4bf088ce24e8eb0c8c3a34595eda71267b03d797 (diff)
downloadpymox-09fd9fa35368f98c33199eccb41e6d9bfe4c84c4.tar.gz
Fixed isinstance check on instances of MockObject.
-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.