예제 #1
0
    def __init__(
        self,
        table,
        expected_table,
        include_columns=None,
        exclude_columns=None,
        report_all=True,
        fail_limit=0,
        report_fail_only=False,
        strict=False,
        description=None,
        category=None,
    ):
        table_entry = TableEntry(table)
        expected_table_entry = TableEntry(expected_table)

        self.table = table_entry.as_list_of_dict()
        self.table_columns = table_entry.columns
        self.expected_table = expected_table_entry.as_list_of_dict()
        self.expected_table_columns = expected_table_entry.columns
        self.include_columns = include_columns
        self.exclude_columns = exclude_columns
        self.strict = strict
        self.report_all = report_all

        self.fail_limit = fail_limit
        self.report_fails_only = report_fail_only

        # these will populated by self.evaluate
        self.display_columns = []
        self.message = None
        self.data = []

        super(TableMatch, self).__init__(description=description,
                                         category=category)
예제 #2
0
def get_table(source, keep_column_order=True):
    """
    Return table formatted as a TableEntry.

    :param source: Tabular data.
    :type source: ``list`` of ``list`` or ``list`` of ``dict``
    :param keep_column_order: Flag whether column order should be maintained.
    :type keep_column_order: ``bool``
    :return: Formatted table.
    :rtype: ``list`` of ``dict``
    """
    if not source:
        return []

    if not isinstance(source, TableEntry):
        table = TableEntry(source)
    return table.as_list_of_dict(keep_column_order=keep_column_order)