def table(self, header=None, rows=None, style=None): """ Return a Table instance. """ if style is not None: style = self.TABLE_STYLES[style] table = Table(style) if header: table.set_header_row(header) if rows: table.set_rows(rows) return table
def test_set_rows(io): table = Table() table.set_rows([["a", "b", "c"], ["d", "e", "f"]]) table.render(io) table.set_row(1, ["g", "h", "i"]) table.render(io) expected = """\ +---+---+---+ | a | b | c | | d | e | f | +---+---+---+ +---+---+---+ | a | b | c | | g | h | i | +---+---+---+ """ assert expected == io.fetch_output()