當前位置: 首頁>>代碼示例>>Python>>正文


Python ddt.unpack方法代碼示例

本文整理匯總了Python中ddt.unpack方法的典型用法代碼示例。如果您正苦於以下問題:Python ddt.unpack方法的具體用法?Python ddt.unpack怎麽用?Python ddt.unpack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ddt的用法示例。


在下文中一共展示了ddt.unpack方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _check_output

# 需要導入模塊: import ddt [as 別名]
# 或者: from ddt import unpack [as 別名]
def _check_output(self, inputs, column_values, **extra_values):
        """Compare generated with expected output."""
        # Namedtuple objects need to be converted to lists on input.
        inputs = [(type(inputval).__name__, list(inputval)) for inputval in inputs]
        output = self._get_reducer_output(inputs)
        if not isinstance(column_values, list):
            column_values = [column_values]
        self.assertEquals(len(output), len(column_values), '{0} != {1}'.format(output, column_values))

        def record_sort_key(record):
            """Sort function for records, by order then by transaction."""
            return record.order_line_item_id, record.transaction_id

        sorted_output = sorted([OrderTransactionRecord.from_job_output(output_tuple[0]) for output_tuple in output],
                               key=record_sort_key)

        for record, expected_columns in zip(sorted_output, column_values):
            # This reducer does the packing in a different way, converting to TSV *before*
            # putting into the output.  So unpack that here, and output as a dict,
            # so that column names can be used instead of numbers.
            output_dict = record._asdict()  # pylint: disable=no-member,protected-access
            expected_columns.update(**extra_values)
            for column_num, expected_value in expected_columns.iteritems():
                self.assertEquals(output_dict[column_num], expected_value) 
開發者ID:edx,項目名稱:edx-analytics-pipeline,代碼行數:26,代碼來源:test_reconcile.py

示例2: annotated_data

# 需要導入模塊: import ddt [as 別名]
# 或者: from ddt import unpack [as 別名]
def annotated_data(*args):
    class List(list):
        pass

    new_args = []

    for arg in args:
        new_arg = List(arg)
        new_arg.__name__ = arg[0]
        new_args.append(new_arg)

    return lambda func: data(*new_args)(unpack(func)) 
開發者ID:lxc,項目名稱:pylxd,代碼行數:14,代碼來源:__init__.py

示例3: combine

# 需要導入模塊: import ddt [as 別名]
# 或者: from ddt import unpack [as 別名]
def combine(**kwargs):
    """Decorator to create combinations and tests
        @combine(level=[0, 1, 2, 3],
                 circuit=[a, b, c, d],
                 dsc='Test circuit {circuit.__name__} with level {level}',
                 name='{circuit.__name__}_level{level}')
    """

    def deco(func):
        return data(*generate_cases(docstring=func.__doc__, **kwargs))(unpack(func))
    return deco 
開發者ID:Qiskit,項目名稱:qiskit-terra,代碼行數:13,代碼來源:__init__.py


注:本文中的ddt.unpack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。