我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用ddt.unpack()。
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))
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)