Skip to content

Commit

Permalink
Merge "Enable list with no dict objects to be sorted in api samples"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 27, 2012
2 parents 7783503 + 24e6e4f commit 0d565de
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions nova/tests/integrated/test_api_samples.py
Expand Up @@ -145,12 +145,15 @@ def _compare_result(self, subs, expected, result):
# which order in different way when using a private key itself or
# its regular expression, and after all doesn't interfere with
# other tests.
# Besides that, there are some cases like Aggregates extension
# where we got a list of strings. For those cases key will be None
# (python's default) and the elements will be compared directly.
# Should we define a criteria when ordering json? Doesn't seems
# necessary so far.
for ex_obj, res_obj in zip(sorted(expected, key=lambda k:
k.get('__tag__', k)),
sorted(result, key=lambda k:
k.get('__tag__', k))):
key = (lambda k: k.get('__tag__', k) if isinstance(k, dict)
else None)
for ex_obj, res_obj in zip(sorted(expected, key=key),
sorted(result, key=key)):
res = self._compare_result(subs, ex_obj, res_obj)
matched_value = res or matched_value

Expand Down

0 comments on commit 0d565de

Please sign in to comment.