diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-09-16 09:09:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-09-16 09:09:35 +0000 |
commit | 0dfe1c9e2780469e3a4696e8fb3e6f717a7ebeb7 (patch) | |
tree | a0b651b55ea02e3b00bbc5eedba566fdd6bd7c08 /tests/test_all_tables_e2e/test_porcelain_table.py | |
parent | Initial commit. (diff) | |
download | terminaltables-0dfe1c9e2780469e3a4696e8fb3e6f717a7ebeb7.tar.xz terminaltables-0dfe1c9e2780469e3a4696e8fb3e6f717a7ebeb7.zip |
Adding upstream version 3.1.0.upstream/3.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_all_tables_e2e/test_porcelain_table.py')
-rw-r--r-- | tests/test_all_tables_e2e/test_porcelain_table.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test_all_tables_e2e/test_porcelain_table.py b/tests/test_all_tables_e2e/test_porcelain_table.py new file mode 100644 index 0000000..7677188 --- /dev/null +++ b/tests/test_all_tables_e2e/test_porcelain_table.py @@ -0,0 +1,59 @@ +"""PorcelainTable end to end testing.""" + +from terminaltables import PorcelainTable + + +def test_single_line(): + """Test single-lined cells.""" + table_data = [ + ['Name', 'Color', 'Type'], + ['Avocado', 'green', 'nut'], + ['Tomato', 'red', 'fruit'], + ['Lettuce', 'green', 'vegetable'], + ['Watermelon', 'green'] + ] + table = PorcelainTable(table_data) + table.justify_columns[0] = 'left' + table.justify_columns[1] = 'center' + table.justify_columns[2] = 'right' + actual = table.table + + expected = ( + ' Name | Color | Type \n' + ' Avocado | green | nut \n' + ' Tomato | red | fruit \n' + ' Lettuce | green | vegetable \n' + ' Watermelon | green | ' + ) + assert actual == expected + + +def test_multi_line(): + """Test multi-lined cells.""" + table_data = [ + ['Show', 'Characters'], + ['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'], + ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick'] + ] + table = PorcelainTable(table_data) + + # Test defaults. + actual = table.table + expected = ( + ' Show | Characters \n' + ' Rugrats | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, \n' + ' | Dil Pickles \n' + ' South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick ' + ) + assert actual == expected + + # Justify right. + table.justify_columns = {1: 'right'} + actual = table.table + expected = ( + ' Show | Characters \n' + ' Rugrats | Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, \n' + ' | Dil Pickles \n' + ' South Park | Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick ' + ) + assert actual == expected |