本文整理汇总了Python中mock.mock.MagicMock.parse_args方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.parse_args方法的具体用法?Python MagicMock.parse_args怎么用?Python MagicMock.parse_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.parse_args方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ParseOptions
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import parse_args [as 别名]
def test_ParseOptions(self, open_mock, backup_file_mock, modify_action_mock, option_parser_mock):
class options(object):
user = "test_user"
hostname = "127.0.0.1"
clustername = "test1"
password = "test_password"
upgrade_json = "catalog_file"
from_stack = "0.0"
to_stack = "1.3"
logfile = "test.log"
report = "report.txt"
warnings = []
printonly = False
args = ["update-configs"]
modify_action_mock.return_value = MagicMock()
backup_file_mock.return_value = MagicMock()
test_mock = MagicMock()
test_mock.parse_args = lambda: (options, args)
option_parser_mock.return_value = test_mock
upgradeHelper.main()
self.assertEqual(backup_file_mock.call_count, 0)
self.assertEqual(modify_action_mock.call_count, 1)
self.assertEqual({"user": options.user, "pass": options.password}, upgradeHelper.Options.API_TOKENS)
self.assertEqual(options.clustername, upgradeHelper.Options.CLUSTER_NAME)