From 6e54ec81feb795a3d31030fd348774b4b8195364 Mon Sep 17 00:00:00 2001 From: xiexs Date: Thu, 19 May 2016 22:59:26 -0400 Subject: [PATCH] Fix the incorrect alignment The "aligns" attribute no longer exists in the Prettytable, "align" instead. So we should use "align" attribute to force the output with left alignment by default. Change-Id: I97b30216000b6e31c1bef614cf0b0d68ab8cfb08 Closes-Bug: #1583880 --- cinderclient/tests/unit/test_utils.py | 16 ++++++++-------- cinderclient/utils.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cinderclient/tests/unit/test_utils.py b/cinderclient/tests/unit/test_utils.py index 347a2d0..f780ade 100644 --- a/cinderclient/tests/unit/test_utils.py +++ b/cinderclient/tests/unit/test_utils.py @@ -221,10 +221,10 @@ class PrintListTestCase(test_utils.TestCase): # Output should be sorted by the first key (a) self.assertEqual("""\ +---+-----+ -| a | b | +| a | b | +---+-----+ | 1 | c d | -| 3 | a | +| 3 | a | +---+-----+ """, cso.read()) @@ -237,12 +237,12 @@ class PrintDictTestCase(test_utils.TestCase): utils.print_dict(d) self.assertEqual("""\ +----------+---------------+ -| Property | Value | +| Property | Value | +----------+---------------+ -| a | A | -| b | B | -| c | C | -| d | test carriage | -| | return | +| a | A | +| b | B | +| c | C | +| d | test carriage | +| | return | +----------+---------------+ """, cso.read()) diff --git a/cinderclient/utils.py b/cinderclient/utils.py index f5a4cb9..950b4bc 100644 --- a/cinderclient/utils.py +++ b/cinderclient/utils.py @@ -160,7 +160,7 @@ def print_list(objs, fields, exclude_unavailable=False, formatters=None, fields.remove(f) pt = prettytable.PrettyTable((f for f in fields), caching=False) - pt.aligns = ['l' for f in fields] + pt.align = 'l' for row in rows: count = 0 # Converts unicode values in dictionary to string @@ -188,7 +188,7 @@ def unicode_key_value_to_string(dictionary): def print_dict(d, property="Property", formatters=None): pt = prettytable.PrettyTable([property, 'Value'], caching=False) - pt.aligns = ['l', 'l'] + pt.align = 'l' formatters = formatters or {} for r in six.iteritems(d):