def test_table_cells_rows(self): tbl = table.Table() for i in range(0, 5): row = table.Row() for j in range(0, 5): cell = table.Cell('cell %d,%d' % (i, j)) row.add_cell(cell) tbl.add_row(row) cell = table.Cell('cell %d' % i) tbl.add_cell(cell) width = int(self._terminal.width() / 2) tbl.draw(self._terminal, width)
def test_table_row_multiline_cell(self): row = table.Row() cells = [ table.Cell('First col'), table.Cell('this cell should span multiple lines'), table.Cell('Third col') ] for cell in cells: row.add_cell(cell) row_len = (sum(x.width(self._terminal) for x in cells) - int(cells[1].width(self._terminal) / 2)) tbl = table.Table() tbl.add_row(row) tbl.draw(self._terminal, row_len)
def test_tables_cells(self): tbl = table.Table() for i in range(0, 20): cell = table.Cell('cell %d' % i) tbl.add_cell(cell) width = int(self._terminal.width() / 2) tbl.draw(self._terminal, width)
def test_table_rows_varying_cells(self): data = [['col 1', 'col 2', 'col 3'], ['xxYYxxYYxx', '-', ''], ['', '-', 'xxYYxxYY']] tbl = table.Table() for r in data: row = table.Row() for c in r: row.add_cell(table.Cell(c)) tbl.add_row(row) tbl.draw(self._terminal, self._terminal.width())