def MockModel(self, model_name, *args, **kwargs):
    test_class_models = self.GetTestClassModule().models

    if not 'models_%s' % model_name in self._set_mock:
      self.mox.StubOutWithMock(
          getattr(self.GetTestClassModule(), 'models'),
          model_name)
      # we need to put back any stubs which MockModelStaticBase placed
      for mock in self._set_mock:
        if mock.startswith('%s:' % model_name):
          self.stubs.Set(
              getattr(test_class_models, model_name),
              mock.split(':')[1],
              self._set_mock[mock])
      self._set_mock['models_%s' % model_name] = 1

    model = self.mox.CreateMockAnything()
    getattr(
        self.GetTestClassModule().models,
        model_name)(*args, **kwargs).AndReturn(model)
    return model
Mock creating an instance of a model, and return the mock instance.
dataset/ETHPy150Open google/simian/src/tests/simian/mac/common/test_base.py/RequestHandlerTest.MockModel