Fixed wrap from taking negative values
Now for wrap input it will take only postive integers as an input and if any negative numbers are give it will give output as "Wrap argument should be a non-negative integer". Change-Id: I39a175e5a30af9128514fef814c6d62d2c283e84 Closes-Bug: #1628797
This commit is contained in:
parent
6425e65d90
commit
38e12731b0
@ -223,6 +223,9 @@ def print_dict(dct, dict_property="Property", wrap=0, dict_value='Value',
|
|||||||
v = six.text_type(v)
|
v = six.text_type(v)
|
||||||
if wrap > 0:
|
if wrap > 0:
|
||||||
v = textwrap.fill(six.text_type(v), wrap)
|
v = textwrap.fill(six.text_type(v), wrap)
|
||||||
|
elif wrap < 0:
|
||||||
|
raise ValueError(_("wrap argument should be a non-negative "
|
||||||
|
"integer"))
|
||||||
# if value has a newline, add in multiple rows
|
# if value has a newline, add in multiple rows
|
||||||
# e.g. fault with stacktrace
|
# e.g. fault with stacktrace
|
||||||
if v and isinstance(v, six.string_types) and r'\n' in v:
|
if v and isinstance(v, six.string_types) and r'\n' in v:
|
||||||
|
@ -663,6 +663,10 @@ class PrintResultStringTestCase(test_base.BaseTestCase):
|
|||||||
'''
|
'''
|
||||||
self.assertEqual(expected, out)
|
self.assertEqual(expected, out)
|
||||||
|
|
||||||
|
def test_print_dict_negative_wrap(self):
|
||||||
|
dct = {"K": "k", "Key": "Value"}
|
||||||
|
self.assertRaises(ValueError, cliutils.print_dict, dct, wrap=-10)
|
||||||
|
|
||||||
|
|
||||||
class DecoratorsTestCase(test_base.BaseTestCase):
|
class DecoratorsTestCase(test_base.BaseTestCase):
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
``--wrap`` CLI argument for ``ironic driver-properties`` and
|
||||||
|
``ironic driver-raid-logical-disk-properties`` commands now takes
|
||||||
|
only non-negative integers as input. An error is shown if a
|
||||||
|
negative value is passed.
|
Loading…
Reference in New Issue
Block a user