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, ): self.table = TableEntry(table).as_list_of_dict() self.expected_table = TableEntry(expected_table).as_list_of_dict() 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 )
def __init__(self, table, display_index=False, description=None): as_list = TableEntry(table).as_list_of_list() self.columns, self.table = as_list[0], as_list[1:] self.indices = range(len(self.table)) self.display_index = display_index super(TableLog, self).__init__(description=description)
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)
def __init__( self, table, values, column, limit=0, report_fails_only=False, description=None, category=None, ): self.table = TableEntry(table).as_list_of_dict() self.values = values self.column = column self.limit = limit self.report_fails_only = report_fails_only self.data = [] # will be set by evaluate super(ColumnContain, self).__init__(description=description, category=category)
def test_validation_success(self, value): TableEntry(value)
def test_validation_failure(self, value): with pytest.raises(ValueError): TableEntry(table=value)
def test_table_columns(self, value, expected): assert TableEntry(value).columns == expected