Public Member Functions | |
def | __call__ (self, *params, **named_params) |
def | __call__ (self, *params, **named_params) |
def | __eq__ (self, rhs) |
def | __eq__ (self, rhs) |
def | __getattr__ (self, name) |
def | __getattr__ (self, name) |
def | __init__ (self, method_name, call_queue, replay_mode) |
def | __init__ (self, method_name, call_queue, replay_mode) |
def | __ne__ (self, rhs) |
def | __ne__ (self, rhs) |
def | __str__ (self) |
def | __str__ (self) |
def | AndRaise (self, exception) |
def | AndRaise (self, exception) |
def | AndReturn (self, return_value) |
def | AndReturn (self, return_value) |
def | GetPossibleGroup (self) |
def | GetPossibleGroup (self) |
def | InAnyOrder (self, group_name="default") |
def | InAnyOrder (self, group_name="default") |
def | MultipleTimes (self, group_name="default") |
def | MultipleTimes (self, group_name="default") |
def | WithSideEffects (self, side_effects) |
def | WithSideEffects (self, side_effects) |
Private Member Functions | |
def | _CheckAndCreateNewGroup (self, group_name, group_class) |
def | _CheckAndCreateNewGroup (self, group_name, group_class) |
def | _PopNextMethod (self) |
def | _PopNextMethod (self) |
def | _VerifyMethodCall (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.
Definition at line 510 of file bloaty/third_party/protobuf/python/mox.py.
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
Definition at line 519 of file bloaty/third_party/protobuf/python/mox.py.
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
Definition at line 519 of file protobuf/python/mox.py.
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.
Definition at line 545 of file bloaty/third_party/protobuf/python/mox.py.
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.
Definition at line 545 of file protobuf/python/mox.py.
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
Definition at line 622 of file protobuf/python/mox.py.
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
Definition at line 622 of file bloaty/third_party/protobuf/python/mox.py.
def mox.MockMethod.__getattr__ | ( | self, | |
name | |||
) |
Raise an AttributeError with a helpful message.
Definition at line 575 of file protobuf/python/mox.py.
def mox.MockMethod.__getattr__ | ( | self, | |
name | |||
) |
Raise an AttributeError with a helpful message.
Definition at line 575 of file bloaty/third_party/protobuf/python/mox.py.
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
Definition at line 635 of file protobuf/python/mox.py.
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
Definition at line 635 of file bloaty/third_party/protobuf/python/mox.py.
def mox.MockMethod.__str__ | ( | self | ) |
Definition at line 615 of file protobuf/python/mox.py.
def mox.MockMethod.__str__ | ( | self | ) |
Definition at line 615 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Checks if the last method (a possible group) is an instance of our group_class. Adds the current method to this group or creates a new one. Args: group_name: the name of the group. group_class: the class used to create instance of this new group
Definition at line 664 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Checks if the last method (a possible group) is an instance of our group_class. Adds the current method to this group or creates a new one. Args: group_name: the name of the group. group_class: the class used to create instance of this new group
Definition at line 664 of file protobuf/python/mox.py.
|
private |
Pop the next method from our call queue.
Definition at line 581 of file protobuf/python/mox.py.
|
private |
Pop the next method from our call queue.
Definition at line 581 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Verify the called method is expected. This can be an ordered method, or part of an unordered set. Returns: The expected mock method. Raises: UnexpectedMethodCall if the method called was not expected.
Definition at line 588 of file protobuf/python/mox.py.
|
private |
Verify the called method is expected. This can be an ordered method, or part of an unordered set. Returns: The expected mock method. Raises: UnexpectedMethodCall if the method called was not expected.
Definition at line 588 of file bloaty/third_party/protobuf/python/mox.py.
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
Definition at line 728 of file protobuf/python/mox.py.
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
Definition at line 728 of file bloaty/third_party/protobuf/python/mox.py.
def mox.MockMethod.AndReturn | ( | self, | |
return_value | |||
) |
Set the value to return when this method is called. Args: # return_value can be anything.
Definition at line 718 of file bloaty/third_party/protobuf/python/mox.py.
def mox.MockMethod.AndReturn | ( | self, | |
return_value | |||
) |
Set the value to return when this method is called. Args: # return_value can be anything.
Definition at line 718 of file protobuf/python/mox.py.
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.
Definition at line 645 of file bloaty/third_party/protobuf/python/mox.py.
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.
Definition at line 645 of file protobuf/python/mox.py.
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
Definition at line 686 of file protobuf/python/mox.py.
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
Definition at line 686 of file bloaty/third_party/protobuf/python/mox.py.
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 method can be called. Args: group_name: the name of the unordered group. Returns: self
Definition at line 704 of file protobuf/python/mox.py.
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
Definition at line 704 of file bloaty/third_party/protobuf/python/mox.py.
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.
Definition at line 738 of file protobuf/python/mox.py.
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.
Definition at line 738 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 534 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 542 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 533 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 540 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 539 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 537 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 541 of file bloaty/third_party/protobuf/python/mox.py.
|
private |
Definition at line 543 of file bloaty/third_party/protobuf/python/mox.py.