def test_simple_2x2_text_table():
    builder = ConsoleTableBuilder(column_width=10)
    builder.set_headers(['Anna', 'Kalle'])
    builder.add_row(['1', '2'])
    builder.add_row(['3', '4'])
    # TODO: Fill in expected string below!
    expected = ''
    actual = builder.get_string_output()
    assert expected == actual
def test_simple_2x2_text_table():
    builder = ConsoleTableBuilder(column_width=10)
    builder.set_headers(['Anna', 'Kalle'])
    builder.add_row(['1', '2'])
    builder.add_row(['3', '4'])
    expected = f'{"Anna":>10}{"Kalle":>10}\n' \
               f'{"1":>10}{"2":>10}\n' \
               f'{"3":>10}{"4":>10}\n'
    got = builder.get_string_output()
    assert expected == got
Exemple #3
0
def test_simple_2x2_text_table():
    builder = ConsoleTableBuilder(column_width=10)
    builder.set_headers(['Anna', 'Kalle'])
    builder.add_row(['1', '2'])
    builder.add_row(['3', '4'])
    expected = '''      Anna     Kalle
         1         2
         3         4
'''
    got = builder.get_string_output()
    assert expected == got
def test_simple_2x2_text_table():
    builder = ConsoleTableBuilder(column_width=10)
    builder.set_headers(['Anna', 'Kalle'])
    builder.add_row(['1', '2'])
    builder.add_row(['3', '4'])

    #expected = "      Anna     Kalle\n         1         2\n         3         4\n"
    expected = "{name1:>10} {name2:>10} {val11:>9} {val12:>10} {val21:>9} {val22:>10}".format(
        name1="Anna",
        name2="Kalle\n",
        val11="1",
        val12="2" + '\n',
        val21="3",
        val22="4\n")
    got = builder.get_string_output()
    assert expected == got