本文整理汇总了Python中salttesting.mock.Mock.assert_called_once_with方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.assert_called_once_with方法的具体用法?Python Mock.assert_called_once_with怎么用?Python Mock.assert_called_once_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类salttesting.mock.Mock
的用法示例。
在下文中一共展示了Mock.assert_called_once_with方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_screen_state
# 需要导入模块: from salttesting.mock import Mock [as 别名]
# 或者: from salttesting.mock.Mock import assert_called_once_with [as 别名]
def test_screen_state(self):
config = {'screen_event': True, 'user': 'frank'}
mock = Mock(return_value=0)
with patch.dict(glxinfo.__salt__, {'cmd.retcode': mock}):
ret = glxinfo.beacon(config)
self.assertEqual(ret, [{'tag': 'screen_event', 'screen_available': True}])
mock.assert_called_once_with('DISPLAY=:0 glxinfo', runas='frank', python_shell=True)
示例2: test_with_user
# 需要导入模块: from salttesting.mock import Mock [as 别名]
# 或者: from salttesting.mock.Mock import assert_called_once_with [as 别名]
def test_with_user(self):
config = {'states': ['device'], 'user': 'fred'}
mock = Mock(return_value='* daemon started successfully *\nList of devices attached\nHTC\tdevice',)
with patch.dict(adb.__salt__, {'cmd.run': mock}):
ret = adb.beacon(config)
mock.assert_called_once_with('adb devices', runas='fred')
self.assertEqual(ret, [{'device': 'HTC', 'state': 'device', 'tag': 'device'}])