From ef6f6674bd28b56104a636bc9c443c1e024006f8 Mon Sep 17 00:00:00 2001 From: Yang Hongyang Date: Sat, 27 Feb 2016 18:07:40 +0800 Subject: [PATCH] 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 --- magnum/tests/unit/api/controllers/v1/test_types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/magnum/tests/unit/api/controllers/v1/test_types.py b/magnum/tests/unit/api/controllers/v1/test_types.py index b863e8c909..af81084168 100644 --- a/magnum/tests/unit/api/controllers/v1/test_types.py +++ b/magnum/tests/unit/api/controllers/v1/test_types.py @@ -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'}]