summaryrefslogtreecommitdiff
path: root/tests/unit/test_cliutils.py
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem@us.ibm.com>2015-10-07 12:31:18 -0700
committerMatt Riedemann <mriedem@us.ibm.com>2015-10-07 12:46:29 -0700
commit075379920e481949a6ff2c4a8b3a9dbeb080ce56 (patch)
tree3ad0d8351a9eba7516abed9e171f7ab3a5ef3683 /tests/unit/test_cliutils.py
parente5fdc5420061faed8c0b709d1746e212cee500e4 (diff)
downloadoslo-incubator-075379920e481949a6ff2c4a8b3a9dbeb080ce56.tar.gz
Allow specifying a table header for the value column in print_dict
If you can provide a customer header label for the property (first) column in the print_dict output you should also be able to provide a customer header label for the value (second) column. Partial-Bug: #1503841 Change-Id: Iaa96b80249389fdf12ffbaf84073debebca4b5a4
Diffstat (limited to 'tests/unit/test_cliutils.py')
-rw-r--r--tests/unit/test_cliutils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_cliutils.py b/tests/unit/test_cliutils.py
index 14acb95b..5a1b8a9e 100644
--- a/tests/unit/test_cliutils.py
+++ b/tests/unit/test_cliutils.py
@@ -591,6 +591,24 @@ class PrintResultStringTestCase(test_base.BaseTestCase):
'''
self.assertEqual(expected, out)
+ def test_print_dict_string_custom_headers(self):
+ orig = sys.stdout
+ sys.stdout = six.StringIO()
+ cliutils.print_dict({"K": "k", "Key": "Value"}, dict_property='Foo',
+ dict_value='Bar')
+ out = sys.stdout.getvalue()
+ sys.stdout.close()
+ sys.stdout = orig
+ expected = '''\
++-----+-------+
+| Foo | Bar |
++-----+-------+
+| K | k |
+| Key | Value |
++-----+-------+
+'''
+ self.assertEqual(expected, out)
+
class DecoratorsTestCase(test_base.BaseTestCase):