diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-21 16:38:12 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-21 16:47:25 -0400 |
commit | ecfecfdd06a3ecdebb749859997c94a311e2efdf (patch) | |
tree | 9c81b7cbce2042290080878be998c63ea88e4bef /tests/test_table_creator.py | |
parent | 77a6c22778ee4514d204849abdb962c21e6dbb54 (diff) | |
download | cmd2-git-ecfecfdd06a3ecdebb749859997c94a311e2efdf.tar.gz |
Made the amount of space between columns in a SimpleTable configurablecolumn_spacing
Diffstat (limited to 'tests/test_table_creator.py')
-rw-r--r-- | tests/test_table_creator.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_table_creator.py b/tests/test_table_creator.py index 6e98baa4..70b77bad 100644 --- a/tests/test_table_creator.py +++ b/tests/test_table_creator.py @@ -338,6 +338,18 @@ def test_simple_table_creation(): 'Col 1 Row 2 Col 2 Row 2 ' ) + # Custom column spacing + st = SimpleTable([column_1, column_2], column_spacing=5) + table = st.generate_table(row_data) + + assert table == ( + 'Col 1 Col 2 \n' + '-------------------------------------\n' + 'Col 1 Row 1 Col 2 Row 1 \n' + '\n' + 'Col 1 Row 2 Col 2 Row 2 ' + ) + # Custom divider st = SimpleTable([column_1, column_2], divider_char='─') table = st.generate_table(row_data) @@ -404,6 +416,11 @@ def test_simple_table_creation(): 'Col 1 Row 2 Col 2 Row 2 ' ) + # Invalid column spacing + with pytest.raises(ValueError) as excinfo: + SimpleTable([column_1, column_2], column_spacing=-1) + assert "Column spacing cannot be less than 0" in str(excinfo.value) + # Invalid divider character with pytest.raises(TypeError) as excinfo: SimpleTable([column_1, column_2], divider_char='too long') |