def annotated_data(*args):
class List(list):
pass
class Dict(dict):
pass
new_args = []
for arg in args:
if isinstance(arg, (list, tuple)):
new_arg = List(arg)
new_arg.__name__ = arg[0]
elif isinstance(arg, dict):
new_arg = Dict(arg)
new_arg.__name__ = arg['tag']
else:
raise TypeError('annotate_data can only handle dicts, '
'lists and tuples')
new_args.append(new_arg)
return lambda func: ddt.data(*new_args)(ddt.unpack(func))
python类unpack()的实例源码
test_firmware_controller.py 文件源码
项目:deb-python-proliantutils
作者: openstack
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def test__extract_scexe_file_issues_command_as(self, utils_trycmd_mock):
# | GIVEN |
any_scexe_firmware_file = 'any_file.scexe'
any_extract_path = 'any_extract_path'
utils_trycmd_mock.return_value = ('out', 'err')
# | WHEN |
firmware_controller._extract_scexe_file(
None, any_scexe_firmware_file, any_extract_path)
# | THEN |
utils_trycmd_mock.assert_called_once_with(
any_scexe_firmware_file, '--unpack=' + any_extract_path)