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

Public Member Functions

def __init__ (self)
 
def __init__ (self)
 
def CreateMock (self, class_to_mock)
 
def CreateMock (self, class_to_mock)
 
def CreateMockAnything (self)
 
def CreateMockAnything (self)
 
def ReplayAll (self)
 
def ReplayAll (self)
 
def ResetAll (self)
 
def ResetAll (self)
 
def StubOutWithMock (self, obj, attr_name, use_mock_anything=False)
 
def StubOutWithMock (self, obj, attr_name, use_mock_anything=False)
 
def UnsetStubs (self)
 
def UnsetStubs (self)
 
def VerifyAll (self)
 
def VerifyAll (self)
 

Public Attributes

 stubs
 

Private Attributes

 _mock_objects
 

Static Private Attributes

list _USE_MOCK_OBJECT
 

Detailed Description

Mox: a factory for creating mock objects.

Definition at line 150 of file bloaty/third_party/protobuf/python/mox.py.

Constructor & Destructor Documentation

◆ __init__() [1/2]

def mox.Mox.__init__ (   self)
Initialize a new Mox.

Definition at line 158 of file bloaty/third_party/protobuf/python/mox.py.

◆ __init__() [2/2]

def mox.Mox.__init__ (   self)
Initialize a new Mox.

Definition at line 158 of file protobuf/python/mox.py.

Member Function Documentation

◆ CreateMock() [1/2]

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 bloaty/third_party/protobuf/python/mox.py.

◆ CreateMock() [2/2]

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 protobuf/python/mox.py.

◆ CreateMockAnything() [1/2]

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 bloaty/third_party/protobuf/python/mox.py.

◆ CreateMockAnything() [2/2]

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 protobuf/python/mox.py.

◆ ReplayAll() [1/2]

def mox.Mox.ReplayAll (   self)
Set all mock objects to replay mode.

Definition at line 189 of file protobuf/python/mox.py.

◆ ReplayAll() [2/2]

def mox.Mox.ReplayAll (   self)
Set all mock objects to replay mode.

Definition at line 189 of file bloaty/third_party/protobuf/python/mox.py.

◆ ResetAll() [1/2]

def mox.Mox.ResetAll (   self)
Call reset on all mock objects.  This does not unset stubs.

Definition at line 202 of file bloaty/third_party/protobuf/python/mox.py.

◆ ResetAll() [2/2]

def mox.Mox.ResetAll (   self)
Call reset on all mock objects.  This does not unset stubs.

Definition at line 202 of file protobuf/python/mox.py.

◆ StubOutWithMock() [1/2]

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 protobuf/python/mox.py.

◆ StubOutWithMock() [2/2]

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 bloaty/third_party/protobuf/python/mox.py.

◆ UnsetStubs() [1/2]

def mox.Mox.UnsetStubs (   self)
Restore stubs to their original state.

Definition at line 230 of file protobuf/python/mox.py.

◆ UnsetStubs() [2/2]

def mox.Mox.UnsetStubs (   self)
Restore stubs to their original state.

Definition at line 230 of file bloaty/third_party/protobuf/python/mox.py.

◆ VerifyAll() [1/2]

def mox.Mox.VerifyAll (   self)
Call verify on all mock objects created.

Definition at line 196 of file protobuf/python/mox.py.

◆ VerifyAll() [2/2]

def mox.Mox.VerifyAll (   self)
Call verify on all mock objects created.

Definition at line 196 of file bloaty/third_party/protobuf/python/mox.py.

Member Data Documentation

◆ _mock_objects

mox.Mox._mock_objects
private

Definition at line 161 of file bloaty/third_party/protobuf/python/mox.py.

◆ _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 bloaty/third_party/protobuf/python/mox.py.

◆ stubs

mox.Mox.stubs

Definition at line 162 of file bloaty/third_party/protobuf/python/mox.py.


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


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:41