summaryrefslogtreecommitdiff
path: root/tests/test_table_creator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_table_creator.py')
-rw-r--r--tests/test_table_creator.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/tests/test_table_creator.py b/tests/test_table_creator.py
index 58dd6fdf..0a0e712d 100644
--- a/tests/test_table_creator.py
+++ b/tests/test_table_creator.py
@@ -20,18 +20,6 @@ from cmd2.table_creator import (
def test_column_creation():
- # No width specified, blank label
- c = Column("")
- assert c.width == 1
-
- # No width specified, label isn't blank but has no width
- c = Column(ansi.style('', fg=ansi.fg.green))
- assert c.width == 1
-
- # No width specified, label has width
- c = Column("short\nreally long")
- assert c.width == ansi.style_aware_wcswidth("really long")
-
# Width less than 1
with pytest.raises(ValueError) as excinfo:
Column("Column 1", width=0)
@@ -46,6 +34,36 @@ def test_column_creation():
Column("Column 1", max_data_lines=0)
assert "Max data lines cannot be less than 1" in str(excinfo.value)
+ # No width specified, blank label
+ c = Column("")
+ assert c.width is None
+ tc = TableCreator([c])
+ assert tc.cols[0].width == 1
+
+ # No width specified, label isn't blank but has no width
+ c = Column(ansi.style('', fg=ansi.fg.green))
+ assert c.width is None
+ tc = TableCreator([c])
+ assert tc.cols[0].width == 1
+
+ # No width specified, label has width
+ c = Column("a line")
+ assert c.width is None
+ tc = TableCreator([c])
+ assert tc.cols[0].width == ansi.style_aware_wcswidth("a line")
+
+ # No width specified, label has width and multiple lines
+ c = Column("short\nreally long")
+ assert c.width is None
+ tc = TableCreator([c])
+ assert tc.cols[0].width == ansi.style_aware_wcswidth("really long")
+
+ # No width specified, label has tabs
+ c = Column("line\twith\ttabs")
+ assert c.width is None
+ tc = TableCreator([c])
+ assert tc.cols[0].width == ansi.style_aware_wcswidth("line with tabs")
+
def test_column_alignment():
column_1 = Column("Col 1", width=10,