Public Member Functions | List of all members
mox.Comparator Class Reference
Inheritance diagram for mox.Comparator:
Inheritance graph
[legend]

Public Member Functions

def __eq__ (self, rhs)
 
def __ne__ (self, rhs)
 
def equals (self, rhs)
 

Detailed Description

Base class for all Mox comparators.

A Comparator can be used as a parameter to a mocked method when the exact
value is not known.  For example, the code you are testing might build up a
long SQL string that is passed to your mock DAO. You're only interested that
the IN clause contains the proper primary keys, so you can set your mock
up as follows:

mock_dao.RunQuery(StrContains('IN (1, 2, 4, 5)')).AndReturn(mock_result)

Now whatever query is passed in must contain the string 'IN (1, 2, 4, 5)'.

A Comparator may replace one or more parameters, for example:
# return at most 10 rows
mock_dao.RunQuery(StrContains('SELECT'), 10)

or

# Return some non-deterministic number of rows
mock_dao.RunQuery(StrContains('SELECT'), IsA(int))

Definition at line 751 of file mox.py.

Member Function Documentation

◆ __eq__()

def mox.Comparator.__eq__ (   self,
  rhs 
)

Definition at line 783 of file mox.py.

◆ __ne__()

def mox.Comparator.__ne__ (   self,
  rhs 
)

Definition at line 786 of file mox.py.

◆ equals()

def mox.Comparator.equals (   self,
  rhs 
)
Special equals method that all comparators must implement.

Args:
  rhs: any python object

Reimplemented in mox.IgnoreArg, mox.Func, mox.Or, mox.And, mox.ContainsKeyValue, mox.In, mox.Regex, mox.StrContains, mox.IsAlmost, mox.IsA, and mox.SameElementsAs.

Definition at line 774 of file mox.py.


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


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:11