Get better format for long lines with PrettyTable
Based on current implement, the cli output format will be bad if the lines are too long. This issue can be fixed by setting 'max_width'. However, there is a bug against it, see https://code.google.com/p/prettytable/source/browse/trunk/CHANGELOG?r=85 line 3. So the requirements.txt is updated as well. docImpact Fixes bug 1251283 Change-Id: I0d4192ad9d10a3d6d47a8319463a5edb57719a68
This commit is contained in:
+13
-7
@@ -68,7 +68,11 @@ class TestUtils(testtools.TestCase):
|
||||
utils.print_list(images, columns)
|
||||
|
||||
sys.stdout = output_dict = StringIO.StringIO()
|
||||
utils.print_dict({'K': 'k', 'Key': 'Value'})
|
||||
utils.print_dict({'K': 'k', 'Key': 'veeeeeeeeeeeeeeeeeeeeeeee'
|
||||
'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
|
||||
'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
|
||||
'eeeeeeeeeeeery long value'},
|
||||
max_column_width=60)
|
||||
|
||||
finally:
|
||||
sys.stdout = saved_stdout
|
||||
@@ -84,12 +88,14 @@ class TestUtils(testtools.TestCase):
|
||||
''')
|
||||
|
||||
self.assertEqual(output_dict.getvalue(), '''\
|
||||
+----------+-------+
|
||||
| Property | Value |
|
||||
+----------+-------+
|
||||
| K | k |
|
||||
| Key | Value |
|
||||
+----------+-------+
|
||||
+----------+--------------------------------------------------------------+
|
||||
| Property | Value |
|
||||
+----------+--------------------------------------------------------------+
|
||||
| K | k |
|
||||
| Key | veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee |
|
||||
| | eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee |
|
||||
| | ery long value |
|
||||
+----------+--------------------------------------------------------------+
|
||||
''')
|
||||
|
||||
def test_exception_to_str(self):
|
||||
|
||||
@@ -90,7 +90,8 @@ class ShellV2Test(testtools.TestCase):
|
||||
utils.print_list.assert_called_once_with({}, ['ID', 'Name'])
|
||||
|
||||
def test_do_image_show(self):
|
||||
args = self._make_args({'id': 'pass', 'page_size': 18})
|
||||
args = self._make_args({'id': 'pass', 'page_size': 18,
|
||||
'max_column_width': 120})
|
||||
with mock.patch.object(self.gc.images, 'get') as mocked_list:
|
||||
ignore_fields = ['self', 'access', 'file', 'schema']
|
||||
expect_image = dict([(field, field) for field in ignore_fields])
|
||||
@@ -100,7 +101,8 @@ class ShellV2Test(testtools.TestCase):
|
||||
test_shell.do_image_show(self.gc, args)
|
||||
|
||||
mocked_list.assert_called_once_with('pass')
|
||||
utils.print_dict.assert_called_once_with({'id': 'pass'})
|
||||
utils.print_dict.assert_called_once_with({'id': 'pass'},
|
||||
max_column_width=120)
|
||||
|
||||
def test_do_image_create_no_user_props(self):
|
||||
args = self._make_args({'name': 'IMG-01', 'disk_format': 'vhd',
|
||||
|
||||
Reference in New Issue
Block a user