diff options
author | Dawid Fatyga <dawid.fatyga@gmail.com> | 2012-04-24 22:53:00 +0200 |
---|---|---|
committer | Dawid Fatyga <dawid.fatyga@gmail.com> | 2012-04-24 22:53:00 +0200 |
commit | 09fd9fa35368f98c33199eccb41e6d9bfe4c84c4 (patch) | |
tree | 3a9f5760e0457ebdecdf03eeb7970af201e1ad46 | |
parent | 4bf088ce24e8eb0c8c3a34595eda71267b03d797 (diff) | |
download | pymox-09fd9fa35368f98c33199eccb41e6d9bfe4c84c4.tar.gz |
Fixed isinstance check on instances of MockObject.
-rwxr-xr-x | mox.py | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -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. |