← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-more-dict-ordering into launchpad:master.

Commit message:
Fix various dict ordering bugs on Python 3.6

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/399296

Python 3.6 makes dicts order-preserving by default, which is great for test reliability, but in some cases the ordering wasn't quite what some tests expected.  Add some more sorting to fix this.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-more-dict-ordering into launchpad:master.
diff --git a/cronscripts/foaf-update-karma-cache.py b/cronscripts/foaf-update-karma-cache.py
index 646fff5..788ea74 100755
--- a/cronscripts/foaf-update-karma-cache.py
+++ b/cronscripts/foaf-update-karma-cache.py
@@ -237,7 +237,7 @@ class KarmaCacheUpdater(LaunchpadCronScript):
         largest_total = max(points_per_category.values())
 
         scaling = {}
-        for category, points in points_per_category.items():
+        for category, points in sorted(points_per_category.items()):
             if points == 0:
                 scaling[category] = 1
             else:
diff --git a/lib/lp/registry/doc/distribution-mirror.txt b/lib/lp/registry/doc/distribution-mirror.txt
index b4fd20a..6cb151c 100644
--- a/lib/lp/registry/doc/distribution-mirror.txt
+++ b/lib/lp/registry/doc/distribution-mirror.txt
@@ -430,10 +430,6 @@ IDistributionMirror.
     dists/breezy-autotest/restricted/binary-i386/Packages.gz
     dists/breezy-autotest/universe/binary-i386/Packages.gz
     dists/breezy-autotest/multiverse/binary-i386/Packages.gz
-    dists/breezy-autotest-backports/main/binary-i386/Packages.gz
-    dists/breezy-autotest-backports/restricted/binary-i386/Packages.gz
-    dists/breezy-autotest-backports/universe/binary-i386/Packages.gz
-    dists/breezy-autotest-backports/multiverse/binary-i386/Packages.gz
     dists/breezy-autotest-security/main/binary-i386/Packages.gz
     dists/breezy-autotest-security/restricted/binary-i386/Packages.gz
     dists/breezy-autotest-security/universe/binary-i386/Packages.gz
@@ -446,26 +442,30 @@ IDistributionMirror.
     dists/breezy-autotest-proposed/restricted/binary-i386/Packages.gz
     dists/breezy-autotest-proposed/universe/binary-i386/Packages.gz
     dists/breezy-autotest-proposed/multiverse/binary-i386/Packages.gz
+    dists/breezy-autotest-backports/main/binary-i386/Packages.gz
+    dists/breezy-autotest-backports/restricted/binary-i386/Packages.gz
+    dists/breezy-autotest-backports/universe/binary-i386/Packages.gz
+    dists/breezy-autotest-backports/multiverse/binary-i386/Packages.gz
     dists/hoary/main/binary-i386/Packages.gz
     dists/hoary/restricted/binary-i386/Packages.gz
-    dists/hoary-backports/main/binary-i386/Packages.gz
-    dists/hoary-backports/restricted/binary-i386/Packages.gz
     dists/hoary-security/main/binary-i386/Packages.gz
     dists/hoary-security/restricted/binary-i386/Packages.gz
     dists/hoary-updates/main/binary-i386/Packages.gz
     dists/hoary-updates/restricted/binary-i386/Packages.gz
     dists/hoary-proposed/main/binary-i386/Packages.gz
     dists/hoary-proposed/restricted/binary-i386/Packages.gz
+    dists/hoary-backports/main/binary-i386/Packages.gz
+    dists/hoary-backports/restricted/binary-i386/Packages.gz
     dists/warty/main/binary-i386/Packages.gz
     dists/warty/universe/binary-i386/Packages.gz
-    dists/warty-backports/main/binary-i386/Packages.gz
-    dists/warty-backports/universe/binary-i386/Packages.gz
     dists/warty-security/main/binary-i386/Packages.gz
     dists/warty-security/universe/binary-i386/Packages.gz
     dists/warty-updates/main/binary-i386/Packages.gz
     dists/warty-updates/universe/binary-i386/Packages.gz
     dists/warty-proposed/main/binary-i386/Packages.gz
     dists/warty-proposed/universe/binary-i386/Packages.gz
+    dists/warty-backports/main/binary-i386/Packages.gz
+    dists/warty-backports/universe/binary-i386/Packages.gz
 
     >>> warty.status = SeriesStatus.OBSOLETE
 
@@ -476,10 +476,6 @@ IDistributionMirror.
     dists/breezy-autotest/restricted/source/Sources.gz
     dists/breezy-autotest/universe/source/Sources.gz
     dists/breezy-autotest/multiverse/source/Sources.gz
-    dists/breezy-autotest-backports/main/source/Sources.gz
-    dists/breezy-autotest-backports/restricted/source/Sources.gz
-    dists/breezy-autotest-backports/universe/source/Sources.gz
-    dists/breezy-autotest-backports/multiverse/source/Sources.gz
     dists/breezy-autotest-security/main/source/Sources.gz
     dists/breezy-autotest-security/restricted/source/Sources.gz
     dists/breezy-autotest-security/universe/source/Sources.gz
@@ -492,16 +488,20 @@ IDistributionMirror.
     dists/breezy-autotest-proposed/restricted/source/Sources.gz
     dists/breezy-autotest-proposed/universe/source/Sources.gz
     dists/breezy-autotest-proposed/multiverse/source/Sources.gz
+    dists/breezy-autotest-backports/main/source/Sources.gz
+    dists/breezy-autotest-backports/restricted/source/Sources.gz
+    dists/breezy-autotest-backports/universe/source/Sources.gz
+    dists/breezy-autotest-backports/multiverse/source/Sources.gz
     dists/hoary/main/source/Sources.gz
     dists/hoary/restricted/source/Sources.gz
-    dists/hoary-backports/main/source/Sources.gz
-    dists/hoary-backports/restricted/source/Sources.gz
     dists/hoary-security/main/source/Sources.gz
     dists/hoary-security/restricted/source/Sources.gz
     dists/hoary-updates/main/source/Sources.gz
     dists/hoary-updates/restricted/source/Sources.gz
     dists/hoary-proposed/main/source/Sources.gz
     dists/hoary-proposed/restricted/source/Sources.gz
+    dists/hoary-backports/main/source/Sources.gz
+    dists/hoary-backports/restricted/source/Sources.gz
     dists/warty-security/main/source/Sources.gz
     dists/warty-updates/main/source/Sources.gz
 
diff --git a/lib/lp/registry/model/distributionmirror.py b/lib/lp/registry/model/distributionmirror.py
index 5c5595e..7d39bae 100644
--- a/lib/lp/registry/model/distributionmirror.py
+++ b/lib/lp/registry/model/distributionmirror.py
@@ -546,7 +546,7 @@ class DistributionMirror(SQLBase):
         """See IDistributionMirror"""
         paths = []
         for series in self.distribution.series:
-            for pocket, suffix in pocketsuffix.items():
+            for pocket, suffix in sorted(pocketsuffix.items()):
                 for component in series.components:
                     for arch_series in series.architectures:
                         # Skip unsupported series and unofficial architectures
@@ -568,7 +568,7 @@ class DistributionMirror(SQLBase):
         """See IDistributionMirror"""
         paths = []
         for series in self.distribution.series:
-            for pocket, suffix in pocketsuffix.items():
+            for pocket, suffix in sorted(pocketsuffix.items()):
                 for component in series.components:
                     # Skip sources for series which are obsolete and ones
                     # which were not on the mirror on its last probe.
diff --git a/lib/lp/soyuz/browser/archive.py b/lib/lp/soyuz/browser/archive.py
index 5b80a58..63361d6 100644
--- a/lib/lp/soyuz/browser/archive.py
+++ b/lib/lp/soyuz/browser/archive.py
@@ -1033,6 +1033,7 @@ class ArchiveView(ArchiveSourcePackageListViewBase):
                 builds = status_summary['builds']
 
             latest_updates_list.append({
+                'source_id': source_id,
                 'date_published': date_published,
                 'title': source_package_name,
                 'status': status_names[current_status.title],
@@ -1042,7 +1043,7 @@ class ArchiveView(ArchiveSourcePackageListViewBase):
                 })
 
         latest_updates_list.sort(
-            key=lambda x: x['date_published'], reverse=True)
+            key=lambda x: (x['date_published'], x['source_id']), reverse=True)
         return latest_updates_list
 
     def num_updates_over_last_days(self, num_days=30):
diff --git a/lib/lp/soyuz/browser/tests/archive-views.txt b/lib/lp/soyuz/browser/tests/archive-views.txt
index d217569..859488d 100644
--- a/lib/lp/soyuz/browser/tests/archive-views.txt
+++ b/lib/lp/soyuz/browser/tests/archive-views.txt
@@ -336,8 +336,8 @@ they were published. We include any relevant builds for failures.
     ...             ))
     >>> print_latest_updates(view.latest_updates)
     cdrkit - Failed to build: i386
-    iceweasel - Successfully built
     pmount - Successfully built
+    iceweasel - Successfully built
 
 Let's now update the datepublished for iceweasel to show that the ordering
 is from most recent.  The view's latest_updates property is cached so we need
@@ -349,8 +349,8 @@ to reload the view.
     >>> login(ANONYMOUS)
     >>> print_latest_updates(view.latest_updates)
     cdrkit - Failed to build: i386
-    iceweasel - Successfully built
     pmount - Successfully built
+    iceweasel - Successfully built
 
 The ArchiveView also includes a helper method to return the number of
 updates over the past month (by default).
diff --git a/lib/lp/translations/utilities/pluralforms.py b/lib/lp/translations/utilities/pluralforms.py
index 8a82685..a52c53e 100644
--- a/lib/lp/translations/utilities/pluralforms.py
+++ b/lib/lp/translations/utilities/pluralforms.py
@@ -49,7 +49,7 @@ def make_friendly_plural_forms(expression, expected_forms):
 
     return [
         {'form': form, 'examples': examples}
-        for (form, examples) in six.iteritems(forms)
+        for (form, examples) in sorted(six.iteritems(forms))
         ]