def test_no_padding_no_borders():
    """Test without padding or borders."""
    row = ['Row One\nColumn One', 'Two', 'Three']
    table = BaseTable([row])
    table.inner_column_border = False
    table.outer_border = False
    table.padding_left = 0
    table.padding_right = 0
    actual = list(table.gen_cell_lines(row, [10, 3, 5], 2))
    expected = [
        ('Row One   ', 'Two', 'Three'),
        ('Column One', '   ', '     '),
    ]
    assert actual == expected
Exemplo n.º 2
0
def test_no_padding_no_borders(style):
    """Test without padding or borders.

    :param str style: Passed to method.
    """
    row = ['Row One\nColumn One', 'Two', 'Three']
    table = BaseTable([row])
    table.inner_column_border = False
    table.outer_border = False
    table.padding_left = 0
    table.padding_right = 0
    actual = [tuple(i) for i in table.gen_row_lines(row, style, [10, 3, 5], 2)]
    expected = [
        ('Row One   ', 'Two', 'Three'),
        ('Column One', '   ', '     '),
    ]
    assert actual == expected
Exemplo n.º 3
0
def test_one_no_rows(mode, bare):
    """Test with one or no rows.

    :param str mode: Type of table contents to test.
    :param bool bare: Disable padding/borders.
    """
    if mode == 'row':
        table_data = [
            ['Avocado', 'green', 'nut'],
        ]
    elif mode == 'one':
        table_data = [
            ['Avocado'],
        ]
    elif mode == 'blank':
        table_data = [
            [''],
        ]
    elif mode == 'empty':
        table_data = [
            [],
        ]
    else:
        table_data = []
    table = BaseTable(table_data)
    if bare:
        table.inner_column_border = False
        table.inner_footing_row_border = False
        table.inner_heading_row_border = False
        table.inner_row_border = False
        table.outer_border = False
        table.padding_left = 0
        table.padding_right = 0
    inner_widths, inner_heights, outer_widths = max_dimensions(
        table_data, table.padding_left, table.padding_right)[:3]
    actual = flatten(table.gen_table(inner_widths, inner_heights,
                                     outer_widths))

    # Determine expected.
    if mode == 'row':
        if bare:
            expected = ('Avocadogreennut')
        else:
            expected = ('+---------+-------+-----+\n'
                        '| Avocado | green | nut |\n'
                        '+---------+-------+-----+')
    elif mode == 'one':
        if bare:
            expected = ('Avocado')
        else:
            expected = ('+---------+\n' '| Avocado |\n' '+---------+')
    elif mode == 'blank':  # Remember there's still padding.
        if bare:
            expected = ('')
        else:
            expected = ('+--+\n' '|  |\n' '+--+')
    elif mode == 'empty':
        if bare:
            expected = ('')
        else:
            expected = ('++\n' '||\n' '++')
    else:
        if bare:
            expected = ('')
        else:
            expected = ('++\n' '++')

    assert actual == expected
Exemplo n.º 4
0
def test_one_no_rows(mode, bare):
    """Test with one or no rows.

    :param str mode: Type of table contents to test.
    :param bool bare: Disable padding/borders.
    """
    if mode == 'row':
        table_data = [
            ['Avocado', 'green', 'nut'],
        ]
    elif mode == 'one':
        table_data = [
            ['Avocado'],
        ]
    elif mode == 'blank':
        table_data = [
            [''],
        ]
    elif mode == 'empty':
        table_data = [
            [],
        ]
    else:
        table_data = [
        ]
    table = BaseTable(table_data)
    if bare:
        table.inner_column_border = False
        table.inner_footing_row_border = False
        table.inner_heading_row_border = False
        table.inner_row_border = False
        table.outer_border = False
        table.padding_left = 0
        table.padding_right = 0
    inner_widths, inner_heights, outer_widths = max_dimensions(table_data, table.padding_left, table.padding_right)[:3]
    actual = flatten(table.gen_table(inner_widths, inner_heights, outer_widths))

    # Determine expected.
    if mode == 'row':
        if bare:
            expected = (
                'Avocadogreennut'
            )
        else:
            expected = (
                '+---------+-------+-----+\n'
                '| Avocado | green | nut |\n'
                '+---------+-------+-----+'
            )
    elif mode == 'one':
        if bare:
            expected = (
                'Avocado'
            )
        else:
            expected = (
                '+---------+\n'
                '| Avocado |\n'
                '+---------+'
            )
    elif mode == 'blank':  # Remember there's still padding.
        if bare:
            expected = (
                ''
            )
        else:
            expected = (
                '+--+\n'
                '|  |\n'
                '+--+'
            )
    elif mode == 'empty':
        if bare:
            expected = (
                ''
            )
        else:
            expected = (
                '++\n'
                '||\n'
                '++'
            )
    else:
        if bare:
            expected = (
                ''
            )
        else:
            expected = (
                '++\n'
                '++'
            )

    assert actual == expected