Fixed a bug when dir() called on MockObject was not returning attributes of a mocked class (Python3).
This commit is contained in:
parent
89f703dc85
commit
4bf088ce24
6
mox.py
6
mox.py
@ -576,7 +576,7 @@ class MockObject(MockAnything):
|
|||||||
self._known_vars = set()
|
self._known_vars = set()
|
||||||
self._class_to_mock = class_to_mock
|
self._class_to_mock = class_to_mock
|
||||||
|
|
||||||
if inspect.isclass(self._class_to_mock):
|
if inspect.isclass(class_to_mock):
|
||||||
self._class_to_bind = self._class_to_mock
|
self._class_to_bind = self._class_to_mock
|
||||||
else:
|
else:
|
||||||
self._class_to_bind = class_to_bind
|
self._class_to_bind = class_to_bind
|
||||||
@ -817,6 +817,10 @@ class MockObject(MockAnything):
|
|||||||
"""Return the name that is being mocked."""
|
"""Return the name that is being mocked."""
|
||||||
return self._description
|
return self._description
|
||||||
|
|
||||||
|
def __dir__(self):
|
||||||
|
"""Return only attributes of a class to mock """
|
||||||
|
return dir(self._class_to_mock)
|
||||||
|
|
||||||
|
|
||||||
class _MockObjectFactory(MockObject):
|
class _MockObjectFactory(MockObject):
|
||||||
"""A MockObjectFactory creates mocks and verifies __init__ params.
|
"""A MockObjectFactory creates mocks and verifies __init__ params.
|
||||||
|
Loading…
Reference in New Issue
Block a user