webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Public Member Functions | List of all members
mox.MockMethod Class Reference
Inheritance diagram for mox.MockMethod:

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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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

Member Function Documentation

◆ __call__()

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.

◆ __eq__()

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

◆ __getattr__()

def mox.MockMethod.__getattr__ (   self,
  name 
)
Raise an AttributeError with a helpful message.

◆ __ne__()

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

◆ __str__()

def mox.MockMethod.__str__ (   self)

◆ AndRaise()

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

◆ AndReturn()

def mox.MockMethod.AndReturn (   self,
  return_value 
)
Set the value to return when this method is called.

Args:
  # return_value can be anything.

◆ GetPossibleGroup()

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.

◆ InAnyOrder()

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

◆ MultipleTimes()

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

◆ WithSideEffects()

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.

The documentation for this class was generated from the following file: