Merge ~cjwatson/launchpad:py3-dict-ordering into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 08fb6cf47ec4b1d07f9702910afa48def89eab6c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-dict-ordering
Merge into: launchpad:master
Diff against target: 226 lines (+39/-34)
8 files modified
lib/lp/bugs/doc/externalbugtracker-rt.txt (+4/-4)
lib/lp/bugs/tests/externalbugtracker.py (+2/-0)
lib/lp/services/statsd/tests/test_numbercruncher.py (+17/-16)
lib/lp/services/webapp/tests/test_errorlog.py (+6/-4)
lib/lp/soyuz/browser/tests/sourcepackage-views.txt (+1/-1)
lib/lp/soyuz/stories/webservice/xx-archive.txt (+6/-6)
lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt (+2/-2)
lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt (+1/-1)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398377@code.launchpad.net

Commit message

Fix tests for different dict ordering in Python 3

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/doc/externalbugtracker-rt.txt b/lib/lp/bugs/doc/externalbugtracker-rt.txt
2index e54eef6..215cf9d 100644
3--- a/lib/lp/bugs/doc/externalbugtracker-rt.txt
4+++ b/lib/lp/bugs/doc/externalbugtracker-rt.txt
5@@ -34,16 +34,16 @@ The default username and password for RT instances are 'guest' and
6 specific credentials for will return the default credentials.
7
8 >>> rt_one = RequestTracker('http://foobar.com')
9- >>> rt_one.credentials
10- {'user': 'guest', 'pass': 'guest'}
11+ >>> print(pretty(rt_one.credentials))
12+ {'pass': 'guest', 'user': 'guest'}
13
14 However, if the RT instance is one for which we have a username and
15 password, those credentials will be retrieved from the Launchpad
16 configuration files. rt.example.com is known to Launchpad.
17
18 >>> rt_two = RequestTracker('http://rt.example.com')
19- >>> rt_two.credentials
20- {'user': 'zaphod', 'pass': 'pangalacticgargleblaster'}
21+ >>> print(pretty(rt_two.credentials))
22+ {'pass': 'pangalacticgargleblaster', 'user': 'zaphod'}
23
24 == Status Conversion ==
25
26diff --git a/lib/lp/bugs/tests/externalbugtracker.py b/lib/lp/bugs/tests/externalbugtracker.py
27index dfac073..b74e45c 100644
28--- a/lib/lp/bugs/tests/externalbugtracker.py
29+++ b/lib/lp/bugs/tests/externalbugtracker.py
30@@ -13,6 +13,7 @@ from datetime import (
31 datetime,
32 timedelta,
33 )
34+from operator import itemgetter
35 import os
36 import random
37 import re
38@@ -1475,6 +1476,7 @@ class TestTracXMLRPCTransport(RequestsTransport):
39 for comment in bug.comments:
40 if comment['id'] in comments:
41 comments_to_return.append(comment)
42+ comments_to_return.sort(key=itemgetter('id'))
43
44 # For each of the missing ones, return a dict with a type of
45 # 'missing'.
46diff --git a/lib/lp/services/statsd/tests/test_numbercruncher.py b/lib/lp/services/statsd/tests/test_numbercruncher.py
47index 3433282..37f8bd3 100644
48--- a/lib/lp/services/statsd/tests/test_numbercruncher.py
49+++ b/lib/lp/services/statsd/tests/test_numbercruncher.py
50@@ -14,6 +14,7 @@ from storm.store import Store
51 from testtools.matchers import (
52 Equals,
53 MatchesListwise,
54+ MatchesSetwise,
55 Not,
56 )
57 from testtools.twistedsupport import AsynchronousDeferredRunTest
58@@ -128,20 +129,20 @@ class TestNumberCruncher(StatsMixin, TestCaseWithFactory):
59 calls = [c[0] for c in self.stats_client.gauge.call_args_list
60 if 'amd64' in c[0][0]]
61 self.assertThat(
62- calls, MatchesListwise(
63- [Equals((
64+ calls, MatchesSetwise(
65+ Equals((
66 'builders,status=disabled,arch=amd64,'
67 'virtualized=True,env=test', 0)),
68- Equals((
69- 'builders,status=building,arch=amd64,'
70- 'virtualized=True,env=test', 2)),
71- Equals((
72- 'builders,status=idle,arch=amd64,'
73- 'virtualized=True,env=test', 4)),
74- Equals((
75- 'builders,status=cleaning,arch=amd64,'
76- 'virtualized=True,env=test', 3))
77- ]))
78+ Equals((
79+ 'builders,status=building,arch=amd64,'
80+ 'virtualized=True,env=test', 2)),
81+ Equals((
82+ 'builders,status=idle,arch=amd64,'
83+ 'virtualized=True,env=test', 4)),
84+ Equals((
85+ 'builders,status=cleaning,arch=amd64,'
86+ 'virtualized=True,env=test', 3))
87+ ))
88
89 def test_updateBuilderStats_error(self):
90 clock = task.Clock()
91@@ -172,11 +173,11 @@ class TestNumberCruncher(StatsMixin, TestCaseWithFactory):
92 self.assertEqual(2, self.stats_client.gauge.call_count)
93 self.assertThat(
94 [x[0] for x in self.stats_client.gauge.call_args_list],
95- MatchesListwise(
96- [Equals(('buildqueue,virtualized=True,arch={},env=test'.format(
97+ MatchesSetwise(
98+ Equals(('buildqueue,virtualized=True,arch={},env=test'.format(
99 build.processor.name), 1)),
100- Equals(('buildqueue,virtualized=False,arch=386,env=test', 1))
101- ]))
102+ Equals(('buildqueue,virtualized=False,arch=386,env=test', 1))
103+ ))
104
105 def test_updateBuilderQueues_error(self):
106 clock = task.Clock()
107diff --git a/lib/lp/services/webapp/tests/test_errorlog.py b/lib/lp/services/webapp/tests/test_errorlog.py
108index d45be30..ff7c4a5 100644
109--- a/lib/lp/services/webapp/tests/test_errorlog.py
110+++ b/lib/lp/services/webapp/tests/test_errorlog.py
111@@ -505,14 +505,15 @@ class TestErrorReportingUtility(TestCaseWithFactory):
112 """The error report should include the oops messages."""
113 utility = ErrorReportingUtility()
114 utility._oops_config.publisher = None
115- with utility.oopsMessage(dict(a='b', c='d')):
116+ message = {'a': 'b', 'c': 'd'}
117+ with utility.oopsMessage(message):
118 try:
119 raise ArbitraryException('foo')
120 except ArbitraryException:
121 info = sys.exc_info()
122 oops = utility._oops_config.create(dict(exc_info=info))
123 self.assertEqual(
124- {'<oops-message-0>': "{'a': 'b', 'c': 'd'}"},
125+ {'<oops-message-0>': str(message)},
126 oops['req_vars'])
127
128 def test__makeErrorReport_combines_request_and_error_vars(self):
129@@ -520,7 +521,8 @@ class TestErrorReportingUtility(TestCaseWithFactory):
130 utility = ErrorReportingUtility()
131 utility._oops_config.publisher = None
132 request = ScriptRequest([('c', 'd')])
133- with utility.oopsMessage(dict(a='b')):
134+ message = {'a': 'b'}
135+ with utility.oopsMessage(message):
136 try:
137 raise ArbitraryException('foo')
138 except ArbitraryException:
139@@ -528,7 +530,7 @@ class TestErrorReportingUtility(TestCaseWithFactory):
140 oops = utility._oops_config.create(
141 dict(exc_info=info, http_request=request))
142 self.assertEqual(
143- {'<oops-message-0>': "{'a': 'b'}", 'c': 'd'},
144+ {'<oops-message-0>': str(message), 'c': 'd'},
145 oops['req_vars'])
146
147 def test_filter_session_statement(self):
148diff --git a/lib/lp/soyuz/browser/tests/sourcepackage-views.txt b/lib/lp/soyuz/browser/tests/sourcepackage-views.txt
149index 398630a..9a38b6c 100644
150--- a/lib/lp/soyuz/browser/tests/sourcepackage-views.txt
151+++ b/lib/lp/soyuz/browser/tests/sourcepackage-views.txt
152@@ -61,7 +61,7 @@ architecturespecific attribute is hidden, i.e, this binary is
153 architecture independent and we don't know at this point, that's why we
154 have only on binary.
155
156- >>> for bin_name, archs in firefox_view.binaries().items():
157+ >>> for bin_name, archs in sorted(firefox_view.binaries().items()):
158 ... print(bin_name, pretty(archs))
159 mozilla-firefox ['hppa', 'i386']
160 mozilla-firefox-data ['hppa', 'i386']
161diff --git a/lib/lp/soyuz/stories/webservice/xx-archive.txt b/lib/lp/soyuz/stories/webservice/xx-archive.txt
162index d613d25..17c4615 100644
163--- a/lib/lp/soyuz/stories/webservice/xx-archive.txt
164+++ b/lib/lp/soyuz/stories/webservice/xx-archive.txt
165@@ -845,26 +845,26 @@ used and displayed via XHR.
166
167 >>> build_counters = webservice.named_get(
168 ... ubuntu['main_archive_link'], 'getBuildCounters').jsonBody()
169- >>> for key, val in build_counters.items():
170+ >>> for key, val in sorted(build_counters.items()):
171 ... print("%s: %s" % (key, val))
172 failed: 5
173- superseded: 3
174- total: 18
175 pending: 2
176 succeeded: 8
177+ superseded: 3
178+ total: 18
179
180 The optional param exclude_needsbuild is also provided:
181
182 >>> build_counters = webservice.named_get(
183 ... ubuntu['main_archive_link'], 'getBuildCounters',
184 ... include_needsbuild=False).jsonBody()
185- >>> for key, val in build_counters.items():
186+ >>> for key, val in sorted(build_counters.items()):
187 ... print("%s: %s" % (key, val))
188 failed: 5
189- superseded: 3
190- total: 17
191 pending: 1
192 succeeded: 8
193+ superseded: 3
194+ total: 17
195
196 Getting published sources and binaries for an IArchive
197 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198diff --git a/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt b/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt
199index 72af5ec..af45f16 100644
200--- a/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt
201+++ b/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt
202@@ -249,9 +249,9 @@ But other URLs result in a 404.
203
204 getDailyDownloadTotals returns a dict mapping dates to total counts.
205
206- >>> for key, value in webservice.named_get(
207+ >>> for key, value in sorted(webservice.named_get(
208 ... firefox['self_link'],
209- ... 'getDailyDownloadTotals').jsonBody().items():
210+ ... 'getDailyDownloadTotals').jsonBody().items()):
211 ... print('%s: %d' % (key, value))
212 2010-02-21: 10
213 2010-02-23: 8
214diff --git a/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt b/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt
215index 0cfdd9c..761b7aa 100644
216--- a/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt
217+++ b/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt
218@@ -350,7 +350,7 @@ service:
219 Create a helper function to print the results:
220
221 >>> def print_build_summaries(summaries):
222- ... for id, summary in summaries.items():
223+ ... for id, summary in sorted(summaries.items()):
224 ... arch_tags = [build['arch_tag'] for build in summary['builds']]
225 ... print("Source ID %s: %s (%s)" % (id, summary['status'],
226 ... pretty(arch_tags)))

Subscribers

People subscribed via source and target branches

to status/vote changes: