Esempio n. 1
0
def test_headerless_table():
    table = Table([
        Line('row_1', 'key_1'),
        Line('row_2', 'key_2'),
    ],
                  header_color=None)
    assert table.construct() == _EXPECTED_HEADERLESS_TABLE
Esempio n. 2
0
def test_default_table():
    table = Table([
        Header('Header'),
        Line('row_1', 'key_1'),
        Spacer(),
        Line('row_2', 'key_2'),
        Line('row_3', 'key_3'),
        Header('Subheader'),
        Line('row_4', 'key_4'),
    ], header_color=None)
    assert table.construct() == _EXPECTED_DEFAULT_RENDER
Esempio n. 3
0
 def _print_test_suites_summary(self, test_suites: TestSuites):
     tests_color = Colors.GREEN if test_suites.tests else Colors.RED
     fails_color = Colors.RED if test_suites.failures else Colors.GREEN
     errors_color = Colors.RED if test_suites.errors else Colors.GREEN
     table = Table([
         Header('Test run summary'),
         Line('Test suites', len(test_suites.test_suites)),
         Line('Total tests ran', test_suites.tests, value_color=tests_color),
         Line('Total tests failed', test_suites.failures, value_color=fails_color),
         Line('Total tests errored', test_suites.errors, value_color=errors_color),
         Line('Total tests skipped', test_suites.skipped)
     ], align_values_left=False)
     self.print(table.construct())
Esempio n. 4
0
def test_custom_table_2():
    table = Table(
        [
            Header('Header'),
            Line('row_1', 'key_1'),
            Spacer(),
            Line('row_2', 'key_2'),
            Line('row_3', 'key_3'),
            Header('Subheader'),
        ],
        header_color=None,
        vertical_separator='o',
        horizontal_separator='o',
        horizontal_hinges=('o', 'o', 'o'),
        vertical_hinges=('o', 'o'),
        corners=('o', 'o', 'o', 'o'),
    )
    assert table.construct() == _EXPECTED_CUSTOM_TABLE_2
Esempio n. 5
0
def test_custom_table_1():
    table = Table(
        [
            Header('Header'),
            Line('row_1', 'key_1'),
            Spacer(),
            Line('row_2', 'key_2'),
            Line('row_3', 'key_3'),
            Header('Subheader'),
            Line('row_4', 'key_4'),
        ],
        header_color=None,
        vertical_separator='|',
        horizontal_separator='-',
        horizontal_hinges=('+', '+', '+'),
        vertical_hinges=('+', '+'),
        corners=('+', '+', '+', '+'),
        left_padding=' < ',
        right_padding=' > ',
    )
    rendered = table.construct()
    assert rendered == _EXPECTED_CUSTOM_TABLE_1
Esempio n. 6
0
    def _print_test_suite(self, test_suite: TestSuite):
        tests_color = Colors.GREEN if test_suite.tests else Colors.RED
        fails_color = Colors.RED if test_suite.failures else Colors.GREEN
        errors_color = Colors.RED if test_suite.errors else Colors.GREEN

        table = Table([
            Header('Testsuite summary'),
            Line('Name', test_suite.name),
            *(Line(p.name.replace('_', ' ').title(), p.value) for p in test_suite.properties),
            Spacer(),
            Line('Total tests ran', test_suite.tests or 0, value_color=tests_color),
            Line('Total tests failed', test_suite.failures or 0, value_color=fails_color),
            Line('Total tests errored', test_suite.errors or 0, value_color=errors_color),
            Line('Total tests skipped', test_suite.skipped or 0),
            *self._get_test_suite_errored_lines(test_suite),
            *self._get_test_suite_failed_lines(test_suite),
            *self._get_test_suite_skipped_lines(test_suite)
        ])

        self.print(table.construct())
Esempio n. 7
0
 def to_line(tc):
     return Line(f'{tc.classname}.{tc.name}', self._truncate(tc.skipped.message))
Esempio n. 8
0
 def to_line(tc):
     return Line(f'{tc.classname}.{tc.name}', self._truncate(tc.failure.message))