Python ddt 模块,unpack() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用ddt.unpack()

项目:nova-lxd    作者:openstack    | 项目源码 | 文件源码
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))
项目:deb-python-proliantutils    作者:openstack    | 项目源码 | 文件源码
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)