Use specific key to sort list of dicts

In python3, sorted() list of dicts will report error:
b'TypeError: unorderable types: dict() < dict()'
This patch fix the problem.

Partially-Implements: blueprint magnum-python3

Change-Id: I5db635712f3128b60d05360ac26a008f49a21850
This commit is contained in:
Yang Hongyang 2016-02-27 18:07:40 +08:00
parent db48e64565
commit ef6f6674bd
1 changed files with 2 additions and 1 deletions

View File

@ -89,7 +89,8 @@ class TestJsonPatchType(base.FunctionalTest):
{'path': '/foo', 'op': 'replace', 'value': 'bar'}]
ret = self._patch_json(valid_patches, False)
self.assertEqual(200, ret.status_int)
self.assertEqual(sorted(valid_patches), sorted(ret.json))
self.assertEqual(sorted(valid_patches, key=lambda k: k['op']),
sorted(ret.json, key=lambda k: k['op']))
def test_cannot_update_internal_attr(self):
patch = [{'path': '/internal', 'op': 'replace', 'value': 'foo'}]