Merge "cinder list now prints dash '-' when data is None"

This commit is contained in:
Jenkins 2015-03-16 21:36:02 +00:00 committed by Gerrit Code Review
commit 7971b36c52
2 changed files with 17 additions and 0 deletions
cinderclient

@ -121,6 +121,21 @@ class PrintListTestCase(test_utils.TestCase):
| 1 | 2 |
| 3 | 4 |
+---+---+
""", cso.read())
def test_print_list_with_None_data(self):
Row = collections.namedtuple('Row', ['a', 'b'])
to_print = [Row(a=3, b=None), Row(a=1, b=2)]
with CaptureStdout() as cso:
utils.print_list(to_print, ['a', 'b'])
# Output should be sorted by the first key (a)
self.assertEqual("""\
+---+---+
| a | b |
+---+---+
| 1 | 2 |
| 3 | - |
+---+---+
""", cso.read())
def test_print_list_with_list_sortby(self):

@ -139,6 +139,8 @@ def print_list(objs, fields, formatters=None, sortby_index=0):
data = o[field]
else:
data = getattr(o, field_name, '')
if data is None:
data = '-'
row.append(data)
pt.add_row(row)