Пример #1
0
 def setUp(self, terminal, theme):
     self._theme = theme
     self._terminal = AnsiTerminal(terminal, theme)
Пример #2
0
    def setUp(self):
        self._terminal = AnsiTerminal(SysTerminal(), Solarized())

        self._terminal.reset()
        self._terminal.write("\n\t# Begin Widget #\n")
Пример #3
0
class ThemeTest(object):
    def setUp(self, terminal, theme):
        self._theme = theme
        self._terminal = AnsiTerminal(terminal, theme)

    def tearDown(self):
        self._terminal.reset()

    def test_percent(self):
        self._terminal.write('Unformatted: %%\n')

    def test_faces(self):
        self._terminal.reset()
        for name in list(self._theme.faces.keys()):
            self._terminal.write('\n\t%%(%s)s[%s]' % (name, name))

        self._terminal.reset()
        self._terminal.write('\n')
Пример #4
0
class WidgetsTest(TestCase):
    def setUp(self):
        self._terminal = AnsiTerminal(SysTerminal(), Solarized())

        self._terminal.reset()
        self._terminal.write("\n\t# Begin Widget #\n")

    def tearDown(self):
        self._terminal.reset()
        self._terminal.write("\t# End Widget #\n")

    def test_section(self):
        section = Section("test section")
        section.draw(self._terminal, self._terminal.width())

        self.assertRaises(AssertionError, section.draw, self._terminal, 1)

    def test_table(self):
        tbl = table.Table()
        tbl.draw(self._terminal, self._terminal.width())

    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_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_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)

        width = int(self._terminal.width() / 2)
        tbl.draw(self._terminal, width)

    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_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())
Пример #5
0
 def setUp(self, terminal, theme):
     self._theme = theme
     self._terminal = AnsiTerminal(terminal, theme)
Пример #6
0
class ThemeTest(object):
    def setUp(self, terminal, theme):
        self._theme = theme
        self._terminal = AnsiTerminal(terminal, theme)

    def tearDown(self):
        self._terminal.reset()

    def test_percent(self):
        self._terminal.write('Unformatted: %%\n')

    def test_faces(self):
        self._terminal.reset()
        for name in self._theme.faces.keys():
            self._terminal.write('\n\t%%(%s)s[%s]' % (name, name))

        self._terminal.reset()
        self._terminal.write('\n')
Пример #7
0
    def setUp(self):
        self._terminal = AnsiTerminal(SysTerminal(), Solarized())

        self._terminal.reset()
        self._terminal.write('\n\t# Begin Widget #\n')
Пример #8
0
class WidgetsTest(TestCase):
    def setUp(self):
        self._terminal = AnsiTerminal(SysTerminal(), Solarized())

        self._terminal.reset()
        self._terminal.write('\n\t# Begin Widget #\n')

    def tearDown(self):
        self._terminal.reset()
        self._terminal.write('\t# End Widget #\n')

    def test_section(self):
        section = Section('test section')
        section.draw(self._terminal, self._terminal.width())

        self.assertRaises(AssertionError, section.draw, self._terminal, 1)

    def test_table(self):
        tbl = table.Table()
        tbl.draw(self._terminal, self._terminal.width())

    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_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_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)

        width = int(self._terminal.width() / 2)
        tbl.draw(self._terminal, width)

    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_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())