本文整理匯總了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)
示例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)
示例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()
示例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)
示例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()
示例6: setUp
# 需要導入模塊: import mox [as 別名]
# 或者: from mox import Mox [as 別名]
def setUp(self):
self.mox = mox.Mox()
self.sample_function_backup = stubout_testee.SampleFunction
示例7: setUp
# 需要導入模塊: import mox [as 別名]
# 或者: from mox import Mox [as 別名]
def setUp(self):
self.mox = mox.Mox()
示例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)
示例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()
示例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)
示例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
示例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)
示例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)
示例14: setUp
# 需要導入模塊: import mox [as 別名]
# 或者: from mox import Mox [as 別名]
def setUp(self):
self.mox = mox.Mox()
self._pytz = cron_handler.pytz
示例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')