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_build/test_build_row.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_build/test_build_row.py')
-rw-r--r-- | tests/test_build/test_build_row.py | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/test_build/test_build_row.py b/tests/test_build/test_build_row.py new file mode 100644 index 0000000..ce55944 --- /dev/null +++ b/tests/test_build/test_build_row.py @@ -0,0 +1,104 @@ +"""Test function in module.""" + +from terminaltables.build import build_row + + +def test_one_line(): + """Test with one line cells.""" + row = [ + ['Left Cell'], ['Center Cell'], ['Right Cell'], + ] + actual = [tuple(i) for i in build_row(row, '>', '|', '<')] + expected = [ + ('>', 'Left Cell', '|', 'Center Cell', '|', 'Right Cell', '<'), + ] + assert actual == expected + + +def test_two_line(): + """Test with two line cells.""" + row = [ + [ + 'Left ', + 'Cell1', + ], + + [ + 'Center', + 'Cell2 ', + ], + + [ + 'Right', + 'Cell3', + ], + ] + actual = [tuple(i) for i in build_row(row, '>', '|', '<')] + expected = [ + ('>', 'Left ', '|', 'Center', '|', 'Right', '<'), + ('>', 'Cell1', '|', 'Cell2 ', '|', 'Cell3', '<'), + ] + assert actual == expected + + +def test_three_line(): + """Test with three line cells.""" + row = [ + [ + 'Left ', + 'Cell1', + ' ', + ], + + [ + 'Center', + 'Cell2 ', + ' ', + ], + + [ + 'Right', + 'Cell3', + ' ', + ], + ] + actual = [tuple(i) for i in build_row(row, '>', '|', '<')] + expected = [ + ('>', 'Left ', '|', 'Center', '|', 'Right', '<'), + ('>', 'Cell1', '|', 'Cell2 ', '|', 'Cell3', '<'), + ('>', ' ', '|', ' ', '|', ' ', '<'), + ] + assert actual == expected + + +def test_single(): + """Test with single cell.""" + actual = [tuple(i) for i in build_row([['Cell']], '>', '|', '<')] + expected = [ + ('>', 'Cell', '<'), + ] + assert actual == expected + + +def test_empty(): + """Test with empty cell.""" + actual = [tuple(i) for i in build_row([['']], '>', '|', '<')] + expected = [ + ('>', '', '<'), + ] + assert actual == expected + + +def test_no_cells(): + """Test with no cells.""" + actual = [tuple(i) for i in build_row([[]], '>', '|', '<')] + expected = [ + ('>', '<'), + ] + assert actual == expected + + actual = [tuple(i) for i in build_row([], '>', '|', '<')] + expected = [ + ('>', '<'), + ] + assert actual == expected |