summaryrefslogtreecommitdiff
path: root/cliff/tests
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2016-02-11 16:31:43 -0500
committerDoug Hellmann <doug@doughellmann.com>2016-02-11 16:32:23 -0500
commitc96658875af585cfaf3aed9a60dc5f27d218241b (patch)
treebbd9c156d0288529949b2a66ccaf43dd6d0525b0 /cliff/tests
parent297f8b81558be17a4e25816f28c4cf6f8557b240 (diff)
downloadcliff-c96658875af585cfaf3aed9a60dc5f27d218241b.tar.gz
handle empty list in table formatter
If there is no data to be formatted, don't try to make sure it fits in the width of the terminal because we're not going to be writing anything anyway. Closes-Bug: #1539770 Change-Id: I877bad1be7a074fccc03f0327b0e43f1e125246c Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Diffstat (limited to 'cliff/tests')
-rw-r--r--cliff/tests/test_formatters_table.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cliff/tests/test_formatters_table.py b/cliff/tests/test_formatters_table.py
index 711ab6b..84ec571 100644
--- a/cliff/tests/test_formatters_table.py
+++ b/cliff/tests/test_formatters_table.py
@@ -227,6 +227,20 @@ def test_table_list_formatter_max_width(tw):
assert len(actual.splitlines()[0]) == expected_width
+@mock.patch('cliff.utils.terminal_width')
+def test_table_list_formatter_empty(tw):
+ tw.return_value = 80
+ sf = table.TableFormatter()
+ c = ('a', 'b', 'c')
+ data = []
+ expected = '\n'
+ output = StringIO()
+ parsed_args = args()
+ sf.emit_list(c, data, output, parsed_args)
+ actual = output.getvalue()
+ assert expected == actual
+
+
def test_field_widths():
tf = table.TableFormatter
assert {