diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 18059bb1..8daaffff 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -56,7 +56,7 @@ def arg(*args, **kwargs): def schema_args(schema_getter, omit=None): omit = omit or [] typemap = { - 'string': str, + 'string': encodeutils.safe_decode, 'integer': int, 'boolean': strutils.bool_from_string, 'array': list diff --git a/glanceclient/tests/unit/test_utils.py b/glanceclient/tests/unit/test_utils.py index c991f3ce..18c54753 100644 --- a/glanceclient/tests/unit/test_utils.py +++ b/glanceclient/tests/unit/test_utils.py @@ -16,6 +16,7 @@ import sys import mock +from oslo_utils import encodeutils import six # NOTE(jokke): simplified transition to py3, behaves like py2 xrange from six.moves import range @@ -152,7 +153,7 @@ class TestUtils(testtools.TestCase): decorated = utils.schema_args(schema_getter())(dummy_func) arg, opts = decorated.__dict__['arguments'][0] self.assertIn('--test', arg) - self.assertEqual(str, opts['type']) + self.assertEqual(encodeutils.safe_decode, opts['type']) decorated = utils.schema_args(schema_getter('integer'))(dummy_func) arg, opts = decorated.__dict__['arguments'][0] @@ -162,7 +163,7 @@ class TestUtils(testtools.TestCase): decorated = utils.schema_args(schema_getter(enum=True))(dummy_func) arg, opts = decorated.__dict__['arguments'][0] self.assertIn('--test', arg) - self.assertEqual(str, opts['type']) + self.assertEqual(encodeutils.safe_decode, opts['type']) self.assertIn('None, opt-1, opt-2', opts['help']) def test_iterable_closes(self):