Mox: a factory for creating mock objects.
Definition at line 150 of file mox.py.
◆ __init__()
def mox.Mox.__init__ |
( |
|
self | ) |
|
Initialize a new Mox.
Definition at line 158 of file mox.py.
◆ CreateMock()
def mox.Mox.CreateMock |
( |
|
self, |
|
|
|
class_to_mock |
|
) |
| |
Create a new mock object.
Args:
# class_to_mock: the class to be mocked
class_to_mock: class
Returns:
MockObject that can be used as the class_to_mock would be.
Definition at line 164 of file mox.py.
◆ CreateMockAnything()
def mox.Mox.CreateMockAnything |
( |
|
self | ) |
|
Create a mock that will accept any method calls.
This does not enforce an interface.
Definition at line 179 of file mox.py.
◆ ReplayAll()
def mox.Mox.ReplayAll |
( |
|
self | ) |
|
Set all mock objects to replay mode.
Definition at line 189 of file mox.py.
◆ ResetAll()
def mox.Mox.ResetAll |
( |
|
self | ) |
|
Call reset on all mock objects. This does not unset stubs.
Definition at line 202 of file mox.py.
◆ StubOutWithMock()
def mox.Mox.StubOutWithMock |
( |
|
self, |
|
|
|
obj, |
|
|
|
attr_name, |
|
|
|
use_mock_anything = False |
|
) |
| |
Replace a method, attribute, etc. with a Mock.
This will replace a class or module with a MockObject, and everything else
(method, function, etc) with a MockAnything. This can be overridden to
always use a MockAnything by setting use_mock_anything to True.
Args:
obj: A Python object (class, module, instance, callable).
attr_name: str. The name of the attribute to replace with a mock.
use_mock_anything: bool. True if a MockAnything should be used regardless
of the type of attribute.
Definition at line 208 of file mox.py.
◆ UnsetStubs()
def mox.Mox.UnsetStubs |
( |
|
self | ) |
|
Restore stubs to their original state.
Definition at line 230 of file mox.py.
◆ VerifyAll()
def mox.Mox.VerifyAll |
( |
|
self | ) |
|
Call verify on all mock objects created.
Definition at line 196 of file mox.py.
◆ _mock_objects
◆ _USE_MOCK_OBJECT
list mox.Mox._USE_MOCK_OBJECT |
|
staticprivate |
Initial value:= [types.ClassType, types.InstanceType, types.ModuleType,
types.ObjectType, types.TypeType]
Definition at line 155 of file mox.py.
◆ stubs
The documentation for this class was generated from the following file: