def test_g6(): # fmt: off g6 = Grid([ Cell("a", x=1, y=1), Cell("bb", x=2, y=1), Cell("cc", x=1, y=2), Cell("d", x=2, y=2) ]) actual = draw(g6) expected = textwrap.dedent("""\ +-----------+-----------+ | a | bb | +-----------+-----------+ | cc | d | +-----------+-----------+""") assert expected == actual
def test_g1(): # fmt: off g1 = Grid([ Cell("aaa", x=1, y=1, width=2), Cell("bb", x=3, y=1), Cell("cc", x=1, y=2), Cell("dddddddddd", x=2, y=2, width=2) ]) actual = draw(g1) expected = textwrap.dedent("""\ +-----------------------+-----------+ | aaa | bb | +-----------+-----------------------+ | cc | ddddddddd | +-----------+-----------------------+""") assert expected == actual
def test_g4(): # fmt: off g4 = Grid([ Cell("aa", x=1, y=1, height=2), Cell("bbb", x=2, y=1, width=2), Cell("ccc", x=2, y=2, height=2), Cell("dd", x=3, y=2), Cell("eeee", x=1, y=3), Cell("ffffff", x=3, y=3), ]) actual = draw(g4) expected = textwrap.dedent("""\ +-----------+-----------------------+ | aa | bbb | | +-----------+-----------+ | | ccc | dd | +-----------| +-----------+ | eeee | | ffffff | +-----------+-----------+-----------+""") assert expected == actual
def test_g5(): # fmt: off g5 = Grid([ Cell("aa", x=1, y=1, height=2), Cell("bb", x=2, y=1), Cell("cccc", x=3, y=1), Cell("ddd", x=2, y=2), Cell("eeeee", x=3, y=2), Cell("ff", x=1, y=3, width=2), Cell("gggggg", x=3, y=3), ]) actual = draw(g5) expected = textwrap.dedent("""\ +-----------+-----------+-----------+ | aa | bb | cccc | | +-----------+-----------+ | | ddd | eeeee | +-----------------------+-----------+ | ff | gggggg | +-----------------------+-----------+""") assert expected == actual
def __str__(self): return draw(self)