Merge lp:~barry/wadllib/lp1132125 into lp:wadllib

Proposed by Barry Warsaw
Status: Merged
Merged at revision: 29
Proposed branch: lp:~barry/wadllib/lp1132125
Merge into: lp:wadllib
Diff against target: 99 lines (+22/-5)
3 files modified
src/wadllib/NEWS.txt (+9/-0)
src/wadllib/README.txt (+10/-2)
src/wadllib/application.py (+3/-3)
To merge this branch: bzr merge lp:~barry/wadllib/lp1132125
Reviewer Review Type Date Requested Status
Gary Poster Approve
Curtis Hovey Pending
Review via email: mp+150439@code.launchpad.net

Description of the change

Fixes the Python 3.3 hash randomization failures by imposing a sort order in a couple of places. This may or may not be semantically correct. The alternative would be to add a urlparsing method to the README and parse the query string into a dict, then compare the dict, but it would make the README uglier.

Please let me know if this solution seems okay. If so, I'll happily merge to trunk, and upload to PyPI and Raring. If not, I'll adjust the tests.

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Hi Barry. I've not looked at this code in a loooong time, but your changes look eminently reasonable to me. Thanks.

Gary

review: Approve
Revision history for this message
Barry Warsaw (barry) wrote :

Thanks! Merging and uploading...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wadllib/NEWS.txt'
2--- src/wadllib/NEWS.txt 2012-03-22 17:01:20 +0000
3+++ src/wadllib/NEWS.txt 2013-02-25 21:26:22 +0000
4@@ -2,6 +2,15 @@
5 NEWS for wadllib
6 ================
7
8+1.3.2 (2013-02-25)
9+==================
10+
11+- Impose sort order to avoid test failures due to hash randomization.
12+ LP: #1132125
13+- Be sure to close streams opened by pkg_resources.resource_stream() to avoid
14+ test suite complaints.
15+
16+
17 1.3.1 (2012-03-22)
18 ==================
19
20
21=== modified file 'src/wadllib/README.txt'
22--- src/wadllib/README.txt 2012-01-27 18:12:53 +0000
23+++ src/wadllib/README.txt 2013-02-25 21:26:22 +0000
24@@ -1,5 +1,5 @@
25 ..
26- Copyright (C) 2008-2009 Canonical Ltd.
27+ Copyright (C) 2008-2013 Canonical Ltd.
28
29 This file is part of wadllib.
30
31@@ -35,9 +35,11 @@
32
33 Or the second argument may be an open filehandle containing the markup.
34
35+ >>> cleanups = []
36 >>> def application_for(filename, url="http://www.example.com/"):
37 ... wadl_stream = pkg_resources.resource_stream(
38 ... 'wadllib.tests.data', filename)
39+ ... cleanups.append(wadl_stream)
40 ... return Application(url, wadl_stream)
41 >>> wadl = application_for("launchpad-wadl.xml",
42 ... "http://api.launchpad.dev/beta/")
43@@ -535,7 +537,7 @@
44
45 >>> create_team_method.build_representation(
46 ... display_name='Joe Bloggs', name='joebloggs')
47- ('application/x-www-form-urlencoded', 'display_name=Joe+Bloggs&ws.op=newTeam&name=joebloggs')
48+ ('application/x-www-form-urlencoded', 'display_name=Joe+Bloggs&name=joebloggs&ws.op=newTeam')
49
50 The return value of build_representation is a 2-tuple containing the
51 media type of the built representation, and the string representation
52@@ -561,6 +563,7 @@
53
54 >>> binary_stream = pkg_resources.resource_stream(
55 ... 'wadllib.tests.data', 'multipart-binary-wadl.xml')
56+ >>> cleanups.append(binary_stream)
57 >>> binary_wadl = Application(
58 ... "http://www.example.com/", binary_stream)
59 >>> service_root = binary_wadl.get_resource_by_path('')
60@@ -647,6 +650,11 @@
61 ... 'post', representation_params={ 'foo' : 'bar' }))
62 None
63
64+.. cleanup
65+ >>> for stream in cleanups:
66+ ... stream.close()
67+
68+
69 .. toctree::
70 :glob:
71
72
73=== modified file 'src/wadllib/application.py'
74--- src/wadllib/application.py 2012-03-12 20:41:45 +0000
75+++ src/wadllib/application.py 2013-02-25 21:26:22 +0000
76@@ -1,4 +1,4 @@
77-# Copyright 2008 Canonical Ltd. All rights reserved.
78+# Copyright 2008-2013 Canonical Ltd. All rights reserved.
79
80 # This file is part of wadllib.
81 #
82@@ -732,7 +732,7 @@
83 append = '&'
84 else:
85 append = '?'
86- url += append + urlencode(validated_values)
87+ url += append + urlencode(sorted(validated_values.items()))
88 return url
89
90
91@@ -834,7 +834,7 @@
92 params, param_values, **kw_param_values)
93 media_type = self.media_type
94 if media_type == 'application/x-www-form-urlencoded':
95- doc = urlencode(validated_values)
96+ doc = urlencode(sorted(validated_values.items()))
97 elif media_type == 'multipart/form-data':
98 outer = MIMEMultipart()
99 outer.set_type('multipart/form-data')

Subscribers

People subscribed via source and target branches