launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26371
[Merge] ~cjwatson/launchpad:py3-dict-ordering into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-dict-ordering into launchpad:master.
Commit message:
Fix tests for different dict ordering in Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398377
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-dict-ordering into launchpad:master.
diff --git a/lib/lp/bugs/doc/externalbugtracker-rt.txt b/lib/lp/bugs/doc/externalbugtracker-rt.txt
index e54eef6..215cf9d 100644
--- a/lib/lp/bugs/doc/externalbugtracker-rt.txt
+++ b/lib/lp/bugs/doc/externalbugtracker-rt.txt
@@ -34,16 +34,16 @@ The default username and password for RT instances are 'guest' and
specific credentials for will return the default credentials.
>>> rt_one = RequestTracker('http://foobar.com')
- >>> rt_one.credentials
- {'user': 'guest', 'pass': 'guest'}
+ >>> print(pretty(rt_one.credentials))
+ {'pass': 'guest', 'user': 'guest'}
However, if the RT instance is one for which we have a username and
password, those credentials will be retrieved from the Launchpad
configuration files. rt.example.com is known to Launchpad.
>>> rt_two = RequestTracker('http://rt.example.com')
- >>> rt_two.credentials
- {'user': 'zaphod', 'pass': 'pangalacticgargleblaster'}
+ >>> print(pretty(rt_two.credentials))
+ {'pass': 'pangalacticgargleblaster', 'user': 'zaphod'}
== Status Conversion ==
diff --git a/lib/lp/bugs/tests/externalbugtracker.py b/lib/lp/bugs/tests/externalbugtracker.py
index dfac073..b74e45c 100644
--- a/lib/lp/bugs/tests/externalbugtracker.py
+++ b/lib/lp/bugs/tests/externalbugtracker.py
@@ -13,6 +13,7 @@ from datetime import (
datetime,
timedelta,
)
+from operator import itemgetter
import os
import random
import re
@@ -1475,6 +1476,7 @@ class TestTracXMLRPCTransport(RequestsTransport):
for comment in bug.comments:
if comment['id'] in comments:
comments_to_return.append(comment)
+ comments_to_return.sort(key=itemgetter('id'))
# For each of the missing ones, return a dict with a type of
# 'missing'.
diff --git a/lib/lp/services/statsd/tests/test_numbercruncher.py b/lib/lp/services/statsd/tests/test_numbercruncher.py
index 3433282..37f8bd3 100644
--- a/lib/lp/services/statsd/tests/test_numbercruncher.py
+++ b/lib/lp/services/statsd/tests/test_numbercruncher.py
@@ -14,6 +14,7 @@ from storm.store import Store
from testtools.matchers import (
Equals,
MatchesListwise,
+ MatchesSetwise,
Not,
)
from testtools.twistedsupport import AsynchronousDeferredRunTest
@@ -128,20 +129,20 @@ class TestNumberCruncher(StatsMixin, TestCaseWithFactory):
calls = [c[0] for c in self.stats_client.gauge.call_args_list
if 'amd64' in c[0][0]]
self.assertThat(
- calls, MatchesListwise(
- [Equals((
+ calls, MatchesSetwise(
+ Equals((
'builders,status=disabled,arch=amd64,'
'virtualized=True,env=test', 0)),
- Equals((
- 'builders,status=building,arch=amd64,'
- 'virtualized=True,env=test', 2)),
- Equals((
- 'builders,status=idle,arch=amd64,'
- 'virtualized=True,env=test', 4)),
- Equals((
- 'builders,status=cleaning,arch=amd64,'
- 'virtualized=True,env=test', 3))
- ]))
+ Equals((
+ 'builders,status=building,arch=amd64,'
+ 'virtualized=True,env=test', 2)),
+ Equals((
+ 'builders,status=idle,arch=amd64,'
+ 'virtualized=True,env=test', 4)),
+ Equals((
+ 'builders,status=cleaning,arch=amd64,'
+ 'virtualized=True,env=test', 3))
+ ))
def test_updateBuilderStats_error(self):
clock = task.Clock()
@@ -172,11 +173,11 @@ class TestNumberCruncher(StatsMixin, TestCaseWithFactory):
self.assertEqual(2, self.stats_client.gauge.call_count)
self.assertThat(
[x[0] for x in self.stats_client.gauge.call_args_list],
- MatchesListwise(
- [Equals(('buildqueue,virtualized=True,arch={},env=test'.format(
+ MatchesSetwise(
+ Equals(('buildqueue,virtualized=True,arch={},env=test'.format(
build.processor.name), 1)),
- Equals(('buildqueue,virtualized=False,arch=386,env=test', 1))
- ]))
+ Equals(('buildqueue,virtualized=False,arch=386,env=test', 1))
+ ))
def test_updateBuilderQueues_error(self):
clock = task.Clock()
diff --git a/lib/lp/services/webapp/tests/test_errorlog.py b/lib/lp/services/webapp/tests/test_errorlog.py
index d45be30..ff7c4a5 100644
--- a/lib/lp/services/webapp/tests/test_errorlog.py
+++ b/lib/lp/services/webapp/tests/test_errorlog.py
@@ -505,14 +505,15 @@ class TestErrorReportingUtility(TestCaseWithFactory):
"""The error report should include the oops messages."""
utility = ErrorReportingUtility()
utility._oops_config.publisher = None
- with utility.oopsMessage(dict(a='b', c='d')):
+ message = {'a': 'b', 'c': 'd'}
+ with utility.oopsMessage(message):
try:
raise ArbitraryException('foo')
except ArbitraryException:
info = sys.exc_info()
oops = utility._oops_config.create(dict(exc_info=info))
self.assertEqual(
- {'<oops-message-0>': "{'a': 'b', 'c': 'd'}"},
+ {'<oops-message-0>': str(message)},
oops['req_vars'])
def test__makeErrorReport_combines_request_and_error_vars(self):
@@ -520,7 +521,8 @@ class TestErrorReportingUtility(TestCaseWithFactory):
utility = ErrorReportingUtility()
utility._oops_config.publisher = None
request = ScriptRequest([('c', 'd')])
- with utility.oopsMessage(dict(a='b')):
+ message = {'a': 'b'}
+ with utility.oopsMessage(message):
try:
raise ArbitraryException('foo')
except ArbitraryException:
@@ -528,7 +530,7 @@ class TestErrorReportingUtility(TestCaseWithFactory):
oops = utility._oops_config.create(
dict(exc_info=info, http_request=request))
self.assertEqual(
- {'<oops-message-0>': "{'a': 'b'}", 'c': 'd'},
+ {'<oops-message-0>': str(message), 'c': 'd'},
oops['req_vars'])
def test_filter_session_statement(self):
diff --git a/lib/lp/soyuz/browser/tests/sourcepackage-views.txt b/lib/lp/soyuz/browser/tests/sourcepackage-views.txt
index 398630a..9a38b6c 100644
--- a/lib/lp/soyuz/browser/tests/sourcepackage-views.txt
+++ b/lib/lp/soyuz/browser/tests/sourcepackage-views.txt
@@ -61,7 +61,7 @@ architecturespecific attribute is hidden, i.e, this binary is
architecture independent and we don't know at this point, that's why we
have only on binary.
- >>> for bin_name, archs in firefox_view.binaries().items():
+ >>> for bin_name, archs in sorted(firefox_view.binaries().items()):
... print(bin_name, pretty(archs))
mozilla-firefox ['hppa', 'i386']
mozilla-firefox-data ['hppa', 'i386']
diff --git a/lib/lp/soyuz/stories/webservice/xx-archive.txt b/lib/lp/soyuz/stories/webservice/xx-archive.txt
index d613d25..17c4615 100644
--- a/lib/lp/soyuz/stories/webservice/xx-archive.txt
+++ b/lib/lp/soyuz/stories/webservice/xx-archive.txt
@@ -845,26 +845,26 @@ used and displayed via XHR.
>>> build_counters = webservice.named_get(
... ubuntu['main_archive_link'], 'getBuildCounters').jsonBody()
- >>> for key, val in build_counters.items():
+ >>> for key, val in sorted(build_counters.items()):
... print("%s: %s" % (key, val))
failed: 5
- superseded: 3
- total: 18
pending: 2
succeeded: 8
+ superseded: 3
+ total: 18
The optional param exclude_needsbuild is also provided:
>>> build_counters = webservice.named_get(
... ubuntu['main_archive_link'], 'getBuildCounters',
... include_needsbuild=False).jsonBody()
- >>> for key, val in build_counters.items():
+ >>> for key, val in sorted(build_counters.items()):
... print("%s: %s" % (key, val))
failed: 5
- superseded: 3
- total: 17
pending: 1
succeeded: 8
+ superseded: 3
+ total: 17
Getting published sources and binaries for an IArchive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt b/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt
index 72af5ec..af45f16 100644
--- a/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt
+++ b/lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt
@@ -249,9 +249,9 @@ But other URLs result in a 404.
getDailyDownloadTotals returns a dict mapping dates to total counts.
- >>> for key, value in webservice.named_get(
+ >>> for key, value in sorted(webservice.named_get(
... firefox['self_link'],
- ... 'getDailyDownloadTotals').jsonBody().items():
+ ... 'getDailyDownloadTotals').jsonBody().items()):
... print('%s: %d' % (key, value))
2010-02-21: 10
2010-02-23: 8
diff --git a/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt b/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt
index 0cfdd9c..761b7aa 100644
--- a/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt
+++ b/lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt
@@ -350,7 +350,7 @@ service:
Create a helper function to print the results:
>>> def print_build_summaries(summaries):
- ... for id, summary in summaries.items():
+ ... for id, summary in sorted(summaries.items()):
... arch_tags = [build['arch_tag'] for build in summary['builds']]
... print("Source ID %s: %s (%s)" % (id, summary['status'],
... pretty(arch_tags)))