本文整理汇总了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')