Merge "Unordered dicts and lists causes variable results"
This commit is contained in:
commit
dcf658cc4e
openstackclient
@ -77,7 +77,7 @@ def format_dict(data):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
output = ""
|
output = ""
|
||||||
for s in data:
|
for s in sorted(data):
|
||||||
output = output + s + "='" + six.text_type(data[s]) + "', "
|
output = output + s + "='" + six.text_type(data[s]) + "', "
|
||||||
return output[:-2]
|
return output[:-2]
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ def format_list(data):
|
|||||||
:rtype: a string formatted to a,b,c
|
:rtype: a string formatted to a,b,c
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return ', '.join(data)
|
return ', '.join(sorted(data))
|
||||||
|
|
||||||
|
|
||||||
def get_item_properties(item, fields, mixed_case_fields=[], formatters={}):
|
def get_item_properties(item, fields, mixed_case_fields=[], formatters={}):
|
||||||
|
@ -130,3 +130,15 @@ class TestFindResource(test_utils.TestCase):
|
|||||||
str(result))
|
str(result))
|
||||||
self.manager.get.assert_called_with(self.name)
|
self.manager.get.assert_called_with(self.name)
|
||||||
self.manager.find.assert_called_with(name=self.name)
|
self.manager.find.assert_called_with(name=self.name)
|
||||||
|
|
||||||
|
def test_format_dict(self):
|
||||||
|
expected = "a='b', c='d', e='f'"
|
||||||
|
self.assertEqual(expected,
|
||||||
|
utils.format_dict({'a': 'b', 'c': 'd', 'e': 'f'}))
|
||||||
|
self.assertEqual(expected,
|
||||||
|
utils.format_dict({'e': 'f', 'c': 'd', 'a': 'b'}))
|
||||||
|
|
||||||
|
def test_format_list(self):
|
||||||
|
expected = 'a, b, c'
|
||||||
|
self.assertEqual(expected, utils.format_list(['a', 'b', 'c']))
|
||||||
|
self.assertEqual(expected, utils.format_list(['c', 'b', 'a']))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user