当前位置: 首页>>代码示例>>Python>>正文


Python mox.Mox方法代码示例

本文整理汇总了Python中mox.Mox方法的典型用法代码示例。如果您正苦于以下问题:Python mox.Mox方法的具体用法?Python mox.Mox怎么用?Python mox.Mox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mox的用法示例。


在下文中一共展示了mox.Mox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    api_server.test_setup_stubs()
    self.mox = mox.Mox()

    self.inst = self.mox.CreateMock(instance.Instance)
    self.environ = {}
    self.start_response = object()
    self.response = [object()]
    self.url_map = object()
    self.match = object()
    self.request_id = object()
    self.auto_server = AutoScalingServerFacade(
        instance_factory=instance.InstanceFactory(object(), 10))
    self.mox.StubOutWithMock(self.auto_server, '_choose_instance')
    self.mox.StubOutWithMock(self.auto_server, '_add_instance')
    self.mox.stubs.Set(time, 'time', lambda: 0.0) 
开发者ID:elsigh,项目名称:browserscope,代码行数:18,代码来源:server_test.py

示例2: testCollectSample

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def testCollectSample(self):
    obj_name = 'InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.'
    obj_param = 'TotalBytesSent'
    sampled_param = periodic_statistics.PeriodicStatistics.SampleSet.Parameter()
    sampled_param.Enable = True
    sampled_param.Reference = obj_name + obj_param
    sample_set = periodic_statistics.PeriodicStatistics.SampleSet()
    m = mox.Mox()
    mock_root = m.CreateMock(tr.core.Exporter)
    mock_root.GetExport(mox.IsA(str)).AndReturn(1000)
    m.ReplayAll()

    sample_set.SetCpeAndRoot(cpe=object(), root=mock_root)
    sample_set.SetParameter('1', sampled_param)
    sample_set.CollectSample()
    m.VerifyAll()

    # Check that the sampled_param updated it's values.
    self.assertEqual('1000', sampled_param.Values) 
开发者ID:omererdem,项目名称:honeything,代码行数:21,代码来源:periodic_statistics_test.py

示例3: testEventQueue

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def testEventQueue(self):
    cpe_machine = self.getCpe()
    m = mox.Mox()
    m.StubOutWithMock(sys, 'exit')
    sys.exit(1)
    sys.exit(1)
    sys.exit(1)
    sys.exit(1)
    m.ReplayAll()

    for i in range(64):
      cpe_machine.event_queue.append(i)

    cpe_machine.event_queue.append(100)
    cpe_machine.event_queue.appendleft(200)
    cpe_machine.event_queue.extend([300])
    cpe_machine.event_queue.extendleft([400])

    cpe_machine.event_queue.clear()
    cpe_machine.event_queue.append(10)
    cpe_machine.event_queue.clear()
    m.VerifyAll() 
开发者ID:omererdem,项目名称:honeything,代码行数:24,代码来源:http_test.py

示例4: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.mox = mox.Mox()
    self.mox.StubOutWithMock(timer.gmacpyutil, 'SetPlistKey')
    self.mox.StubOutWithMock(timer.gmacpyutil, 'GetPlistKey')

    self.timeplist = '/tmp/blah/myapp.plist'
    self.interval = datetime.timedelta(hours=23)
    self.tf = timer.TimeFile(self.timeplist) 
开发者ID:google,项目名称:macops,代码行数:10,代码来源:timer_test.py

示例5: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.mox = mox.Mox()
    self.mox.StubOutWithMock(ds.gmacpyutil, 'RunProcess')
    if os.uname()[0] == 'Linux':
      self.InitMockFoundation()
    elif os.uname()[0] == 'Darwin':
      self.StubFoundation() 
开发者ID:google,项目名称:macops,代码行数:9,代码来源:ds_test.py

示例6: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.mox = mox.Mox()
    self.sample_function_backup = stubout_testee.SampleFunction 
开发者ID:elsigh,项目名称:browserscope,代码行数:5,代码来源:stubout_test.py

示例7: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.mox = mox.Mox() 
开发者ID:elsigh,项目名称:browserscope,代码行数:4,代码来源:mox_test.py

示例8: testCreateObject

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def testCreateObject(self):
    """Mox should create a mock object."""
    mock_obj = self.mox.CreateMock(TestClass) 
开发者ID:elsigh,项目名称:browserscope,代码行数:5,代码来源:mox_test.py

示例9: testVerifyObjectWithCompleteReplay

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def testVerifyObjectWithCompleteReplay(self):
    """Mox should replay and verify all objects it created."""
    mock_obj = self.mox.CreateMock(TestClass)
    mock_obj.ValidCall()
    mock_obj.ValidCallWithArgs(mox.IsA(TestClass))
    self.mox.ReplayAll()
    mock_obj.ValidCall()
    mock_obj.ValidCallWithArgs(TestClass("some_value"))
    self.mox.VerifyAll() 
开发者ID:elsigh,项目名称:browserscope,代码行数:11,代码来源:mox_test.py

示例10: testVerifyObjectWithIncompleteReplay

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def testVerifyObjectWithIncompleteReplay(self):
    """Mox should raise an exception if a mock didn't replay completely."""
    mock_obj = self.mox.CreateMock(TestClass)
    mock_obj.ValidCall()
    self.mox.ReplayAll()
    # ValidCall() is never made
    self.assertRaises(mox.ExpectedMethodCallsError, self.mox.VerifyAll) 
开发者ID:elsigh,项目名称:browserscope,代码行数:9,代码来源:mox_test.py

示例11: _setUpTestClass

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def _setUpTestClass(self):
    """Replacement for setUp in the test class instance.

    Assigns a mox.Mox instance as the mox attribute of the test class instance.
    This replacement Mox instance is under our control before setUp is called
    in the test class instance.
    """
    self.test.mox = self.test_mox 
开发者ID:elsigh,项目名称:browserscope,代码行数:10,代码来源:mox_test.py

示例12: testMultipleInheritance

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def testMultipleInheritance(self):
    """Should be able to access members created by all parent setUp()."""
    self.assert_(isinstance(self.mox, mox.Mox))
    self.assertEquals(42, self.critical_variable) 
开发者ID:elsigh,项目名称:browserscope,代码行数:6,代码来源:mox_test.py

示例13: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.mox = mox.Mox()
    self.proxy = self.mox.CreateMock(instance.RuntimeProxy)
    self.environ = object()
    self.start_response = object()
    self.url_map = object()
    self.match = object()
    self.request_id = object()
    self.response = [object()]
    self.request_data = self.mox.CreateMock(wsgi_request_info.WSGIRequestInfo) 
开发者ID:elsigh,项目名称:browserscope,代码行数:12,代码来源:instance_test.py

示例14: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.mox = mox.Mox()
    self._pytz = cron_handler.pytz 
开发者ID:elsigh,项目名称:browserscope,代码行数:5,代码来源:cron_handler_test.py

示例15: setUp

# 需要导入模块: import mox [as 别名]
# 或者: from mox import Mox [as 别名]
def setUp(self):
    self.app_id = 'myapp'
    os.environ['APPLICATION_ID'] = self.app_id
    api_server.test_setup_stubs(app_id=self.app_id)

    self.mox = mox.Mox()
    self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                             'render') 
开发者ID:elsigh,项目名称:browserscope,代码行数:10,代码来源:datastore_viewer_test.py


注:本文中的mox.Mox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。