From 59f980abc3aa10e0ff8a3d38ed91d69f68b194ed Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Thu, 6 Nov 2014 20:39:25 -0500 Subject: When we switch to tox, we'll get hash randomization, which breaks many tests. While I'm shipping a tox.ini, do not yet use tox to run the tests, unless you want to help fix the randomizations. In the meantime, I'm also adding a few randomization fixes, and updating to the latest falcon git trunk. --- src/mailman/rest/helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/mailman/rest/helpers.py') diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py index acc5106be..f67d9d448 100644 --- a/src/mailman/rest/helpers.py +++ b/src/mailman/rest/helpers.py @@ -46,6 +46,7 @@ from datetime import datetime, timedelta from enum import Enum from lazr.config import as_boolean from mailman.config import config +from pprint import pformat @@ -103,8 +104,10 @@ def etag(resource): :rtype string """ assert 'http_etag' not in resource, 'Resource already etagged' - etag = hashlib.sha1(repr(resource)).hexdigest() - + # Calculate the tag from a predictable (i.e. sorted) representation of the + # dictionary. The actual details aren't so important. pformat() is + # guaranteed to sort the keys. + etag = hashlib.sha1(pformat(resource)).hexdigest() resource['http_etag'] = '"{0}"'.format(etag) return json.dumps(resource, cls=ExtendedEncoder) -- cgit v1.2.3-70-g09d2