Public Member Functions | |
def | __call__ (self, *params, **named_params) |
def | __eq__ (self, rhs) |
def | __getattr__ (self, name) |
def | __init__ (self, method_name, call_queue, replay_mode) |
def | __ne__ (self, rhs) |
def | __str__ (self) |
def | AndRaise (self, exception) |
def | AndReturn (self, return_value) |
def | GetPossibleGroup (self) |
def | InAnyOrder (self, group_name="default") |
def | MultipleTimes (self, group_name="default") |
def | WithSideEffects (self, side_effects) |
Private Member Functions | |
def | _CheckAndCreateNewGroup (self, group_name, group_class) |
def | _PopNextMethod (self) |
def | _VerifyMethodCall (self) |
Private Attributes | |
_call_queue | |
_exception | |
_name | |
_named_params | |
_params | |
_replay_mode | |
_return_value | |
_side_effects | |
Callable mock method. A MockMethod should act exactly like the method it mocks, accepting parameters and returning a value, or throwing an exception (as specified). When this method is called, it can optionally verify whether the called method (name and signature) matches the expected method.
def mox.MockMethod.__init__ | ( | self, | |
method_name, | |||
call_queue, | |||
replay_mode | |||
) |
Construct a new mock method. Args: # method_name: the name of the method # call_queue: deque of calls, verify this call against the head, or add # this call to the queue. # replay_mode: False if we are recording, True if we are verifying calls # against the call queue. method_name: str call_queue: list or deque replay_mode: bool
def mox.MockMethod.__call__ | ( | self, | |
* | params, | ||
** | named_params | ||
) |
Log parameters and return the specified return value. If the Mock(Anything/Object) associated with this call is in record mode, this MockMethod will be pushed onto the expected call queue. If the mock is in replay mode, this will pop a MockMethod off the top of the queue and verify this call is equal to the expected call. Raises: UnexpectedMethodCall if this call is supposed to match an expected method call and it does not.
def mox.MockMethod.__eq__ | ( | self, | |
rhs | |||
) |
def mox.MockMethod.__getattr__ | ( | self, | |
name | |||
) |
def mox.MockMethod.__ne__ | ( | self, | |
rhs | |||
) |
|
private |
|
private |
|
private |
def mox.MockMethod.AndRaise | ( | self, | |
exception | |||
) |
def mox.MockMethod.AndReturn | ( | self, | |
return_value | |||
) |
def mox.MockMethod.GetPossibleGroup | ( | self | ) |
def mox.MockMethod.InAnyOrder | ( | self, | |
group_name = "default" |
|||
) |
Move this method into a group of unordered calls. A group of unordered calls must be defined together, and must be executed in full before the next expected method can be called. There can be multiple groups that are expected serially, if they are given different group names. The same group name can be reused if there is a standard method call, or a group with a different name, spliced between usages. Args: group_name: the name of the unordered group. Returns: self
def mox.MockMethod.MultipleTimes | ( | self, | |
group_name = "default" |
|||
) |
Move this method into group of calls which may be called multiple times. A group of repeating calls must be defined together, and must be executed in full before the next expected mehtod can be called. Args: group_name: the name of the unordered group. Returns: self
def mox.MockMethod.WithSideEffects | ( | self, | |
side_effects | |||
) |