Public Member Functions | |
def | __call__ (self, *params, **named_params) |
def | __class__ (self) |
def | __eq__ (self, rhs) |
def | __getattr__ (self, name) |
def | __getitem__ (self, key) |
def | __init__ (self, class_to_mock) |
def | __setitem__ (self, key, value) |
![]() | |
def | __init__ (self) |
def | __ne__ (self, rhs) |
def | __nonzero__ (self) |
Private Attributes | |
_class_to_mock | |
_expected_calls_queue | |
_known_methods | |
_known_vars | |
_replay_mode | |
A mock object that simulates the public/protected interface of a class.
def mox.MockObject.__init__ | ( | self, | |
class_to_mock | |||
) |
def mox.MockObject.__call__ | ( | self, | |
* | params, | ||
** | named_params | ||
) |
def mox.MockObject.__class__ | ( | self | ) |
def mox.MockObject.__eq__ | ( | self, | |
rhs | |||
) |
Provide custom logic to compare objects.
Reimplemented from mox.MockAnything.
def mox.MockObject.__getattr__ | ( | self, | |
name | |||
) |
Intercept attribute request on this object. If the attribute is a public class variable, it will be returned and not recorded as a call. If the attribute is not a variable, it is handled like a method call. The method name is checked against the set of mockable methods, and a new MockMethod is returned that is aware of the MockObject's state (record or replay). The call will be recorded or replayed by the MockMethod's __call__. Args: # name: the name of the attribute being requested. name: str Returns: Either a class variable or a new MockMethod that is aware of the state of the mock (record or replay). Raises: UnknownMethodCallError if the MockObject does not mock the requested method.
Reimplemented from mox.MockAnything.
def mox.MockObject.__getitem__ | ( | self, | |
key | |||
) |
Provide custom logic for mocking classes that are subscriptable. Args: key: Key to return the value for. Returns: Expected return value in replay mode. A MockMethod object for the __getitem__ method that has already been called if not in replay mode. Raises: TypeError if the underlying class is not subscriptable. UnexpectedMethodCallError if the object does not expect the call to __setitem__.
def mox.MockObject.__setitem__ | ( | self, | |
key, | |||
value | |||
) |
Provide custom logic for mocking classes that support item assignment. Args: key: Key to set the value for. value: Value to set. Returns: Expected return value in replay mode. A MockMethod object for the __setitem__ method that has already been called if not in replay mode. Raises: TypeError if the underlying class does not support item assignment. UnexpectedMethodCallError if the object does not expect the call to __setitem__.