From e169704084099091112097b72bb45859ad05ec4e Mon Sep 17 00:00:00 2001 From: Kui Shi Date: Mon, 21 Oct 2013 06:56:56 +0800 Subject: [PATCH] align the order of parameters for urlencode() In Python 3.3, hash randomization is enabled by default. It causes the iteration order of dicts and sets to be unpredictable and differ across Python runs. In the test case, the fixed expecting string will not match the test result, it is relying on the dict order. This change transforms the input dict to a sequence of two-element list, with fixed order, and exchange the order of "limit" and "marker" for expecting string. Partial implement: blueprint py33-support Change-Id: If9c25fb0d457b31034111e7e879f1f95a576a78f --- heatclient/tests/test_stacks.py | 4 ++-- heatclient/v1/stacks.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/heatclient/tests/test_stacks.py b/heatclient/tests/test_stacks.py index b671a72b..6216068d 100644 --- a/heatclient/tests/test_stacks.py +++ b/heatclient/tests/test_stacks.py @@ -251,9 +251,9 @@ class StackManagerPaginationTest(testtools.TestCase): offset = result[0] url = '/stacks?' - if offset > 0: - url += 'marker=abcd1234-%s&' % offset url += 'limit=%s' % self.page_size + if offset > 0: + url += '&marker=abcd1234-%s' % offset self.assertEqual(url, arg_url) def results(): diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py index c196e235..06874bcf 100644 --- a/heatclient/v1/stacks.py +++ b/heatclient/v1/stacks.py @@ -72,7 +72,8 @@ class StackManager(base.Manager): absolute_limit = kwargs.get('limit') def paginate(qp, seen=0): - url = '/stacks?%s' % urlutils.urlencode(qp) + sort_qp = sorted(qp.items(), key=lambda x: x[0]) + url = '/stacks?%s' % urlutils.urlencode(sort_qp) stacks = self._list(url, "stacks") for stack in stacks: