當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。