diff options
Diffstat (limited to 'tests/test_tabulate.py')
-rw-r--r-- | tests/test_tabulate.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_tabulate.py b/tests/test_tabulate.py new file mode 100644 index 0000000..37e86bf --- /dev/null +++ b/tests/test_tabulate.py @@ -0,0 +1,34 @@ +import itertools +from rich.style import Style +from rich.table import _Cell +from rich.tabulate import tabulate_mapping + + +def test_tabulate_mapping(): + # TODO: tabulate_mapping may not be needed shortly + table = tabulate_mapping({"foo": "1", "bar": "2"}) + assert len(table.columns) == 2 + assert len(table.columns[0]._cells) == 2 + assert len(table.columns[1]._cells) == 2 + + # add tests for title and caption justification + test_title = "Foo v. Bar" + test_caption = "approximate results" + for title_justify, caption_justify in itertools.product( + [None, "left", "center", "right"], repeat=2 + ): + table = tabulate_mapping( + {"foo": "1", "bar": "2"}, + title=test_title, + caption=test_caption, + title_justify=title_justify, + caption_justify=caption_justify, + ) + expected_title_justify = ( + title_justify if title_justify is not None else "center" + ) + expected_caption_justify = ( + caption_justify if caption_justify is not None else "center" + ) + assert expected_title_justify == table.title_justify + assert expected_caption_justify == table.caption_justify |