webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
Public Member Functions | |
def | __init__ (self, method_name, call_queue, replay_mode) |
def | __call__ (self, params, named_params) |
def | __getattr__ (self, name) |
def | __str__ (self) |
def | __eq__ (self, rhs) |
def | __ne__ (self, rhs) |
def | GetPossibleGroup (self) |
def | InAnyOrder (self, group_name="default") |
def | MultipleTimes (self, group_name="default") |
def | AndReturn (self, return_value) |
def | AndRaise (self, exception) |
def | WithSideEffects (self, 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 | |||
) |
Test whether this MockMethod is equivalent to another MockMethod. Args: # rhs: the right hand side of the test rhs: MockMethod
def mox.MockMethod.__getattr__ | ( | self, | |
name | |||
) |
Raise an AttributeError with a helpful message.
def mox.MockMethod.__ne__ | ( | self, | |
rhs | |||
) |
Test whether this MockMethod is not equivalent to another MockMethod. Args: # rhs: the right hand side of the test rhs: MockMethod
def mox.MockMethod.__str__ | ( | self | ) |
def mox.MockMethod.AndRaise | ( | self, | |
exception | |||
) |
Set the exception to raise when this method is called. Args: # exception: the exception to raise when this method is called. exception: Exception
def mox.MockMethod.AndReturn | ( | self, | |
return_value | |||
) |
Set the value to return when this method is called. Args: # return_value can be anything.
def mox.MockMethod.GetPossibleGroup | ( | self | ) |
Returns a possible group from the end of the call queue or None if no other methods are on the stack.
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 | |||
) |
Set the side effects that are simulated when this method is called. Args: side_effects: A callable which modifies the parameters or other relevant state which a given test case depends on. Returns: Self for chaining with AndReturn and AndRaise.