← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Use assertContentEqual() instead of sorted()

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This works better on Python 3, where model instances aren't orderable.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-more-assertContentEqual into launchpad:master.
diff --git a/lib/lp/blueprints/model/tests/test_specification.py b/lib/lp/blueprints/model/tests/test_specification.py
index b9afaeb..4264e9f 100644
--- a/lib/lp/blueprints/model/tests/test_specification.py
+++ b/lib/lp/blueprints/model/tests/test_specification.py
@@ -73,12 +73,10 @@ class TestSpecificationDependencies(TestCaseWithFactory):
         do_next.createDependency(do_first)
         do_last = self.factory.makeBlueprint()
         do_last.createDependency(do_next)
-        self.assertThat(sorted(do_first.getBlockedSpecs()), Equals([do_next]))
-        self.assertThat(
-            sorted(do_first.all_blocked()), Equals(sorted([do_next, do_last])))
-        self.assertThat(sorted(do_last.getDependencies()), Equals([do_next]))
-        self.assertThat(
-            sorted(do_last.all_deps()), Equals(sorted([do_first, do_next])))
+        self.assertContentEqual([do_next], do_first.getBlockedSpecs())
+        self.assertContentEqual([do_next, do_last], do_first.all_blocked())
+        self.assertContentEqual([do_next], do_last.getDependencies())
+        self.assertContentEqual([do_first, do_next], do_last.all_deps())
 
     def test_diamond_dependency(self):
         #             do_first
@@ -94,18 +92,14 @@ class TestSpecificationDependencies(TestCaseWithFactory):
         do_last = self.factory.makeBlueprint()
         do_last.createDependency(do_next_lhs)
         do_last.createDependency(do_next_rhs)
-        self.assertThat(
-            sorted(do_first.getBlockedSpecs()),
-            Equals(sorted([do_next_lhs, do_next_rhs])))
-        self.assertThat(
-            sorted(do_first.all_blocked()),
-            Equals(sorted([do_next_lhs, do_next_rhs, do_last])))
-        self.assertThat(
-            sorted(do_last.getDependencies()),
-            Equals(sorted([do_next_lhs, do_next_rhs])))
-        self.assertThat(
-            sorted(do_last.all_deps()),
-            Equals(sorted([do_first, do_next_lhs, do_next_rhs])))
+        self.assertContentEqual(
+            [do_next_lhs, do_next_rhs], do_first.getBlockedSpecs())
+        self.assertContentEqual(
+            [do_next_lhs, do_next_rhs, do_last], do_first.all_blocked())
+        self.assertContentEqual(
+            [do_next_lhs, do_next_rhs], do_last.getDependencies())
+        self.assertContentEqual(
+            [do_first, do_next_lhs, do_next_rhs], do_last.all_deps())
 
     def test_all_deps_filters(self):
         # all_deps, when provided a user, shows only the dependencies the user
diff --git a/lib/lp/bugs/model/tests/test_bugtask.py b/lib/lp/bugs/model/tests/test_bugtask.py
index 7466f7e..ec8c2e1 100644
--- a/lib/lp/bugs/model/tests/test_bugtask.py
+++ b/lib/lp/bugs/model/tests/test_bugtask.py
@@ -1589,11 +1589,9 @@ class TestBugTaskMilestones(TestCaseWithFactory):
             self.product_bug.default_bugtask,
             self.distribution_bug.default_bugtask,
             ]
-        milestones = sorted(
+        self.assertContentEqual(
+            [self.product_milestone, self.distribution_milestone],
             self.bugtaskset.getBugTaskTargetMilestones(tasks))
-        self.assertEqual(
-            sorted([self.product_milestone, self.distribution_milestone]),
-            milestones)
 
 
 class TestConjoinedBugTasks(TestCaseWithFactory):
diff --git a/lib/lp/code/model/tests/test_branchcollection.py b/lib/lp/code/model/tests/test_branchcollection.py
index 35fce20..b02a942 100644
--- a/lib/lp/code/model/tests/test_branchcollection.py
+++ b/lib/lp/code/model/tests/test_branchcollection.py
@@ -264,10 +264,9 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         branch_a = self.factory.makeProductBranch(product=aardvark)
         branch_b = self.factory.makeProductBranch(product=badger)
         branch_c = self.factory.makePersonalBranch()
-        self.assertEqual(
-            sorted([branch_a, branch_b, branch_c]),
-            sorted(self.all_branches.getBranches()
-                 .order_by(Branch.target_suffix)))
+        self.assertContentEqual(
+            [branch_a, branch_b, branch_c],
+            self.all_branches.getBranches().order_by(Branch.target_suffix))
 
     def test_count_respects_visibleByUser_filter(self):
         # IBranchCollection.count() returns the number of branches that
@@ -452,8 +451,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         # And a product branch.
         self.factory.makeProductBranch()
         collection = self.all_branches.inDistribution(distro)
-        self.assertEqual(
-            sorted([branch, branch2]), sorted(collection.getBranches()))
+        self.assertContentEqual([branch, branch2], collection.getBranches())
 
     def test_in_distro_series(self):
         # 'inDistroSeries' returns a new collection that only has branches
@@ -471,8 +469,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         # And a product branch.
         self.factory.makeProductBranch()
         collection = self.all_branches.inDistroSeries(series_one)
-        self.assertEqual(
-            sorted([branch, branch2]), sorted(collection.getBranches()))
+        self.assertContentEqual([branch, branch2], collection.getBranches())
 
     def _makeOffical(self, branch, pocket):
         registrant = branch.sourcepackage.distribution.owner
@@ -489,8 +486,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         self.factory.makePackageBranch()
         self.factory.makePackageBranch()
         collection = self.all_branches.officialBranches()
-        self.assertEqual(
-            sorted([branch1, branch2]), sorted(collection.getBranches()))
+        self.assertContentEqual([branch1, branch2], collection.getBranches())
 
     def test_official_branches_pocket(self):
         # If passed a pocket, `officialBranches` returns a new collection that
@@ -504,8 +500,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         self.factory.makePackageBranch()
         collection = self.all_branches.officialBranches(
             PackagePublishingPocket.BACKPORTS)
-        self.assertEqual(
-            sorted([branch2]), sorted(collection.getBranches()))
+        self.assertContentEqual([branch2], collection.getBranches())
 
     def test_in_distribution_source_package(self):
         # 'inDistributionSourcePackage' returns a new collection that only has
@@ -533,8 +528,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
             sourcepackagename=package, distribution=series_one.distribution)
         collection = self.all_branches.inDistributionSourcePackage(
             distro_source_package)
-        self.assertEqual(
-            sorted([branch, branch2]), sorted(collection.getBranches()))
+        self.assertContentEqual([branch, branch2], collection.getBranches())
 
     def test_withLifecycleStatus(self):
         # 'withLifecycleStatus' returns a new collection that only has
@@ -550,9 +544,8 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         collection = self.all_branches.withLifecycleStatus(
             BranchLifecycleStatus.DEVELOPMENT,
             BranchLifecycleStatus.MATURE)
-        self.assertEqual(
-            sorted([branch1, branch3, branch4]),
-            sorted(collection.getBranches()))
+        self.assertContentEqual(
+            [branch1, branch3, branch4], collection.getBranches())
 
     def test_withIds(self):
         # 'withIds' returns a new collection that only has branches with the
@@ -562,9 +555,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
         self.factory.makeAnyBranch()
         ids = [branch1.id, branch2.id]
         collection = self.all_branches.withIds(*ids)
-        self.assertEqual(
-            sorted([branch1, branch2]),
-            sorted(collection.getBranches()))
+        self.assertContentEqual([branch1, branch2], collection.getBranches())
 
     def test_registeredBy(self):
         # 'registeredBy' returns a new collection that only has branches that
@@ -601,9 +592,9 @@ class TestBranchCollectionFilters(TestCaseWithFactory):
             branch_type=BranchType.IMPORTED)
         branches = self.all_branches.withBranchType(
             BranchType.HOSTED, BranchType.MIRRORED)
-        self.assertEqual(
-            sorted([hosted_branch1, hosted_branch2, mirrored_branch]),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            [hosted_branch1, hosted_branch2, mirrored_branch],
+            branches.getBranches())
 
     def test_scanned(self):
         scanned_branch = self.factory.makeAnyBranch()
@@ -696,11 +687,11 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory):
     def test_all_branches(self):
         # Without the visibleByUser filter, all branches are in the
         # collection.
-        self.assertEqual(
-            sorted([self.public_branch, self.private_branch1,
-                 self.private_branch2, self.public_stacked_on_branch,
-                 self.private_stacked_on_branch]),
-            sorted(self.all_branches.getBranches()))
+        self.assertContentEqual(
+            [self.public_branch, self.private_branch1,
+             self.private_branch2, self.public_stacked_on_branch,
+             self.private_stacked_on_branch],
+            self.all_branches.getBranches())
 
     def test_anonymous_sees_only_public(self):
         # Anonymous users can see only public branches.
@@ -727,16 +718,14 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory):
         # branches.
         owner = removeSecurityProxy(self.private_branch1).owner
         branches = self.all_branches.visibleByUser(owner)
-        self.assertEqual(
-            sorted([self.public_branch, self.private_branch1]),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            [self.public_branch, self.private_branch1], branches.getBranches())
 
     def test_launchpad_services_sees_all(self):
         # The LAUNCHPAD_SERVICES special user sees *everything*.
         branches = self.all_branches.visibleByUser(LAUNCHPAD_SERVICES)
-        self.assertEqual(
-            sorted(self.all_branches.getBranches()),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            self.all_branches.getBranches(), branches.getBranches())
 
     def test_admins_see_all(self):
         # Launchpad administrators see *everything*.
@@ -745,9 +734,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory):
             getUtility(ILaunchpadCelebrities).admin)
         admin_team.addMember(admin, admin_team.teamowner)
         branches = self.all_branches.visibleByUser(admin)
-        self.assertEqual(
-            sorted(self.all_branches.getBranches()),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            self.all_branches.getBranches(), branches.getBranches())
 
     def test_subscribers_can_see_branches(self):
         # A person subscribed to a branch can see it, even if it's private.
@@ -758,9 +746,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory):
             CodeReviewNotificationLevel.NOEMAIL,
             subscriber)
         branches = self.all_branches.visibleByUser(subscriber)
-        self.assertEqual(
-            sorted([self.public_branch, self.private_branch1]),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            [self.public_branch, self.private_branch1], branches.getBranches())
 
     def test_subscribed_team_members_can_see_branches(self):
         # A person in a team that is subscribed to a branch can see that
@@ -780,9 +767,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory):
         # Members of the team can see the private branch that the team is
         # subscribed to.
         branches = self.all_branches.visibleByUser(team_owner)
-        self.assertEqual(
-            sorted([self.public_branch, private_branch]),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            [self.public_branch, private_branch], branches.getBranches())
 
     def test_private_teams_see_own_private_junk_branches(self):
         # Private teams are given an acess grant to see their private +junk
@@ -804,9 +790,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory):
             self.factory.makePersonalBranch(
                 information_type=InformationType.USERDATA)
             branches = self.all_branches.visibleByUser(team)
-        self.assertEqual(
-            sorted([self.public_branch, personal_branch]),
-            sorted(branches.getBranches()))
+        self.assertContentEqual(
+            [self.public_branch, personal_branch], branches.getBranches())
 
 
 class TestExtendedBranchRevisionDetails(TestCaseWithFactory):
@@ -856,7 +841,7 @@ class TestExtendedBranchRevisionDetails(TestCaseWithFactory):
 
         result = self.all_branches.getExtendedRevisionDetails(
             branch.owner, branch_revisions)
-        self.assertEqual(sorted(expected_rev_details), sorted(result))
+        self.assertContentEqual(expected_rev_details, result)
 
     def test_some_revisions_with_bugs(self):
         branch = self.factory.makeBranch()
@@ -876,7 +861,7 @@ class TestExtendedBranchRevisionDetails(TestCaseWithFactory):
         expected_rev_details[0]['linked_bugtasks'] = linked_bugtasks
         result = self.all_branches.getExtendedRevisionDetails(
             branch.owner, branch_revisions)
-        self.assertEqual(sorted(expected_rev_details), sorted(result))
+        self.assertContentEqual(expected_rev_details, result)
 
     def test_some_revisions_with_private_bugs(self):
         branch = self.factory.makeBranch()
@@ -903,7 +888,7 @@ class TestExtendedBranchRevisionDetails(TestCaseWithFactory):
         person = self.factory.makePerson()
         result = self.all_branches.getExtendedRevisionDetails(
             person, branch_revisions)
-        self.assertEqual(sorted(expected_rev_details), sorted(result))
+        self.assertContentEqual(expected_rev_details, result)
 
 
 class TestBranchMergeProposals(TestCaseWithFactory):
@@ -967,7 +952,7 @@ class TestBranchMergeProposals(TestCaseWithFactory):
             target_branch=target, source_branch=branch3)
         collection = self.all_branches.ownedBy(person)
         proposals = collection.getMergeProposals()
-        self.assertEqual(sorted([mp1, mp2]), sorted(proposals))
+        self.assertContentEqual([mp1, mp2], proposals)
 
     def test_preloading_for_previewdiff(self):
         product = self.factory.makeProduct()
@@ -1020,10 +1005,10 @@ class TestBranchMergeProposals(TestCaseWithFactory):
         collection = self.all_branches
         result = collection.getMergeProposals(
             target_branch=target, merged_revnos=[123])
-        self.assertEqual(sorted([mp1, mp2]), sorted(result))
+        self.assertContentEqual([mp1, mp2], result)
         result = collection.getMergeProposals(
             target_branch=target, merged_revnos=[123, 321])
-        self.assertEqual(sorted([mp1, mp2, mp3]), sorted(result))
+        self.assertContentEqual([mp1, mp2, mp3], result)
 
     def test_target_branch_private(self):
         # The target branch must be in the branch collection, as must the
@@ -1046,7 +1031,7 @@ class TestBranchMergeProposals(TestCaseWithFactory):
         proposals = self.all_branches.getMergeProposals(
             [BranchMergeProposalStatus.WORK_IN_PROGRESS,
              BranchMergeProposalStatus.NEEDS_REVIEW])
-        self.assertEqual(sorted([mp1, mp2]), sorted(proposals))
+        self.assertContentEqual([mp1, mp2], proposals)
 
     def test_status_restriction_with_product_filter(self):
         # getMergeProposals returns the merge proposals with a particular
@@ -1270,7 +1255,7 @@ class TestSearch(TestCaseWithFactory):
         branch2 = self.factory.makeAnyBranch(name='foo')
         self.factory.makeAnyBranch()
         search_results = self.collection.search('foo')
-        self.assertEqual(sorted([branch1, branch2]), sorted(search_results))
+        self.assertContentEqual([branch1, branch2], search_results)
 
     def test_match_against_unique_name(self):
         branch = self.factory.makeAnyBranch(name='fooa')
@@ -1285,7 +1270,7 @@ class TestSearch(TestCaseWithFactory):
         branch2 = self.factory.makeAnyBranch(name='foob')
         self.factory.makeAnyBranch()
         search_results = self.collection.search('foo')
-        self.assertEqual(sorted([branch1, branch2]), sorted(search_results))
+        self.assertContentEqual([branch1, branch2], search_results)
 
     def test_match_ignores_case(self):
         branch = self.factory.makeAnyBranch(name='foobar')
diff --git a/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py b/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py
index c16d36e..debec5e 100644
--- a/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py
+++ b/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py
@@ -131,9 +131,7 @@ class TestGetOfficialSourcePackageLinksForBranches(TestCaseWithFactory):
         make_linked_package_branch(self.factory)
         links = (BranchListingQueryOptimiser.
                  getOfficialSourcePackageLinksForBranches([b1.id, b2.id]))
-        self.assertEqual(
-            sorted([b1, b2]),
-            sorted([link.branch for link in links]))
+        self.assertContentEqual([b1, b2], [link.branch for link in links])
 
     def test_objects_loaded(self):
         # Traversing through the source package and the distribution should
diff --git a/lib/lp/code/model/tests/test_gitcollection.py b/lib/lp/code/model/tests/test_gitcollection.py
index 447fcb4..2c72590 100644
--- a/lib/lp/code/model/tests/test_gitcollection.py
+++ b/lib/lp/code/model/tests/test_gitcollection.py
@@ -220,10 +220,10 @@ class TestGitCollectionFilters(TestCaseWithFactory):
         person = self.factory.makePerson()
         repository_c = self.factory.makeGitRepository(
             owner=person, target=person)
-        self.assertEqual(
-            sorted([repository_a, repository_b, repository_c]),
-            sorted(self.all_repositories.getRepositories()
-                 .order_by(GitRepository.name)))
+        self.assertContentEqual(
+            [repository_a, repository_b, repository_c],
+            self.all_repositories.getRepositories()
+                .order_by(GitRepository.name))
 
     def test_count_respects_visibleByUser_filter(self):
         # IGitCollection.count() returns the number of repositories that
@@ -393,9 +393,8 @@ class TestGitCollectionFilters(TestCaseWithFactory):
         # And a project repository.
         self.factory.makeGitRepository()
         collection = self.all_repositories.inDistribution(distro)
-        self.assertEqual(
-            sorted([repository, repository2]),
-            sorted(collection.getRepositories()))
+        self.assertContentEqual(
+            [repository, repository2], collection.getRepositories())
 
     def test_in_distribution_source_package(self):
         # 'inDistributionSourcePackage' returns a new collection that only
@@ -408,9 +407,8 @@ class TestGitCollectionFilters(TestCaseWithFactory):
         self.factory.makeGitRepository(target=dsp_other_distro)
         self.factory.makeGitRepository()
         collection = self.all_repositories.inDistributionSourcePackage(dsp)
-        self.assertEqual(
-            sorted([repository, repository2]),
-            sorted(collection.getRepositories()))
+        self.assertContentEqual(
+            [repository, repository2], collection.getRepositories())
 
     def test_in_oci_project(self):
         # 'inOCIProject' returns a new collection that only
@@ -422,9 +420,8 @@ class TestGitCollectionFilters(TestCaseWithFactory):
         self.factory.makeGitRepository(target=ocip_other_distro)
         self.factory.makeGitRepository()
         collection = self.all_repositories.inOCIProject(ocip)
-        self.assertEqual(
-            sorted([repository, repository2]),
-            sorted(collection.getRepositories()))
+        self.assertContentEqual(
+            [repository, repository2], collection.getRepositories())
 
     def test_withIds(self):
         # 'withIds' returns a new collection that only has repositories with
@@ -434,9 +431,8 @@ class TestGitCollectionFilters(TestCaseWithFactory):
         self.factory.makeGitRepository()
         ids = [repository1.id, repository2.id]
         collection = self.all_repositories.withIds(*ids)
-        self.assertEqual(
-            sorted([repository1, repository2]),
-            sorted(collection.getRepositories()))
+        self.assertContentEqual(
+            [repository1, repository2], collection.getRepositories())
 
     def test_registeredBy(self):
         # 'registeredBy' returns a new collection that only has repositories
@@ -538,7 +534,7 @@ class TestBranchMergeProposals(TestCaseWithFactory):
             target_ref=target, source_ref=ref3)
         collection = self.all_repositories.ownedBy(person)
         proposals = collection.getMergeProposals()
-        self.assertEqual(sorted([mp1, mp2]), sorted(proposals))
+        self.assertContentEqual([mp1, mp2], proposals)
 
     def test_preloading_for_previewdiff(self):
         project = self.factory.makeProduct()
@@ -615,7 +611,7 @@ class TestBranchMergeProposals(TestCaseWithFactory):
         proposals = self.all_repositories.getMergeProposals(
             [BranchMergeProposalStatus.WORK_IN_PROGRESS,
              BranchMergeProposalStatus.NEEDS_REVIEW])
-        self.assertEqual(sorted([mp1, mp2]), sorted(proposals))
+        self.assertContentEqual([mp1, mp2], proposals)
 
     def test_status_restriction_with_project_filter(self):
         # getMergeProposals returns the merge proposals with a particular
@@ -648,7 +644,7 @@ class TestBranchMergeProposals(TestCaseWithFactory):
         self.factory.makeBranchMergeProposalForGit()
         proposals = self.all_repositories.getMergeProposals(
             target_repository=mp1.target_git_repository)
-        self.assertEqual(sorted([mp1, mp2]), sorted(proposals))
+        self.assertContentEqual([mp1, mp2], proposals)
 
     def test_specifying_target_ref(self):
         # If the target_repository and target_path are specified, only merge
@@ -671,7 +667,7 @@ class TestBranchMergeProposals(TestCaseWithFactory):
         self.factory.makeBranchMergeProposalForGit()
         proposals = self.all_repositories.getMergeProposals(
             prerequisite_repository=ref1.repository)
-        self.assertEqual(sorted([mp1, mp2]), sorted(proposals))
+        self.assertContentEqual([mp1, mp2], proposals)
 
     def test_specifying_prerequisite_ref(self):
         # If the prerequisite_repository and prerequisite_path are
@@ -773,9 +769,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory):
     def test_all_repositories(self):
         # Without the visibleByUser filter, all repositories are in the
         # collection.
-        self.assertEqual(
-            sorted([self.public_repository, self.private_repository]),
-            sorted(self.all_repositories.getRepositories()))
+        self.assertContentEqual(
+            [self.public_repository, self.private_repository],
+            self.all_repositories.getRepositories())
 
     def test_anonymous_sees_only_public(self):
         # Anonymous users can see only public repositories.
@@ -804,16 +800,16 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory):
         # public repositories.
         owner = removeSecurityProxy(self.private_repository).owner
         repositories = self.all_repositories.visibleByUser(owner)
-        self.assertEqual(
-            sorted([self.public_repository, self.private_repository]),
-            sorted(repositories.getRepositories()))
+        self.assertContentEqual(
+            [self.public_repository, self.private_repository],
+            repositories.getRepositories())
 
     def test_launchpad_services_sees_all(self):
         # The LAUNCHPAD_SERVICES special user sees *everything*.
         repositories = self.all_repositories.visibleByUser(LAUNCHPAD_SERVICES)
-        self.assertEqual(
-            sorted(self.all_repositories.getRepositories()),
-            sorted(repositories.getRepositories()))
+        self.assertContentEqual(
+            self.all_repositories.getRepositories(),
+            repositories.getRepositories())
 
     def test_admins_see_all(self):
         # Launchpad administrators see *everything*.
@@ -822,9 +818,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory):
             getUtility(ILaunchpadCelebrities).admin)
         admin_team.addMember(admin, admin_team.teamowner)
         repositories = self.all_repositories.visibleByUser(admin)
-        self.assertEqual(
-            sorted(self.all_repositories.getRepositories()),
-            sorted(repositories.getRepositories()))
+        self.assertContentEqual(
+            self.all_repositories.getRepositories(),
+            repositories.getRepositories())
 
     def test_subscribers_can_see_repositories(self):
         # A person subscribed to a repository can see it, even if it's
@@ -836,9 +832,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory):
             CodeReviewNotificationLevel.NOEMAIL,
             subscriber)
         repositories = self.all_repositories.visibleByUser(subscriber)
-        self.assertEqual(
-            sorted([self.public_repository, self.private_repository]),
-            sorted(repositories.getRepositories()))
+        self.assertContentEqual(
+            [self.public_repository, self.private_repository],
+            repositories.getRepositories())
 
     def test_subscribed_team_members_can_see_repositories(self):
         # A person in a team that is subscribed to a repository can see that
@@ -856,9 +852,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory):
         # Members of the team can see the private repository that the team
         # is subscribed to.
         repositories = self.all_repositories.visibleByUser(team_owner)
-        self.assertEqual(
-            sorted([self.public_repository, self.private_repository]),
-            sorted(repositories.getRepositories()))
+        self.assertContentEqual(
+            [self.public_repository, self.private_repository],
+            repositories.getRepositories())
 
     def test_private_teams_see_own_private_personal_repositories(self):
         # Private teams are given an access grant to see their private
@@ -883,9 +879,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory):
                 owner=other_person, target=other_person,
                 information_type=InformationType.USERDATA)
             repositories = self.all_repositories.visibleByUser(team)
-        self.assertEqual(
-            sorted([self.public_repository, personal_repository]),
-            sorted(repositories.getRepositories()))
+        self.assertContentEqual(
+            [self.public_repository, personal_repository],
+            repositories.getRepositories())
 
 
 class TestSearch(TestCaseWithFactory):
@@ -993,8 +989,7 @@ class TestSearch(TestCaseWithFactory):
         repository2 = self.factory.makeGitRepository(name='foo')
         self.factory.makeGitRepository()
         search_results = self.collection.search('foo')
-        self.assertEqual(
-            sorted([repository1, repository2]), sorted(search_results))
+        self.assertContentEqual([repository1, repository2], search_results)
 
     def disabled_test_match_against_unique_name(self):
         # XXX cjwatson 2015-02-06: Disabled until the URL format settles
@@ -1011,8 +1006,7 @@ class TestSearch(TestCaseWithFactory):
         repository2 = self.factory.makeGitRepository(name='foob')
         self.factory.makeGitRepository()
         search_results = self.collection.search('foo')
-        self.assertEqual(
-            sorted([repository1, repository2]), sorted(search_results))
+        self.assertContentEqual([repository1, repository2], search_results)
 
     def test_match_ignores_case(self):
         repository = self.factory.makeGitRepository(name='foobar')
diff --git a/lib/lp/code/model/tests/test_revisioncache.py b/lib/lp/code/model/tests/test_revisioncache.py
index 2f5ea2d..9f531c3 100644
--- a/lib/lp/code/model/tests/test_revisioncache.py
+++ b/lib/lp/code/model/tests/test_revisioncache.py
@@ -150,9 +150,8 @@ class TestRevisionCache(TestCaseWithFactory):
                                  revision_collection):
         # Check that the revisions returned from the revision collection match
         # the expected revisions.
-        self.assertEqual(
-            sorted(expected_revisions),
-            sorted(revision_collection.getRevisions()))
+        self.assertContentEqual(
+            expected_revisions, revision_collection.getRevisions())
 
     def test_private_revisions(self):
         # Private flags are honoured when only requesting public revisions.
diff --git a/lib/lp/code/model/tests/test_seriessourcepackagebranch.py b/lib/lp/code/model/tests/test_seriessourcepackagebranch.py
index 0721868..b03f860 100644
--- a/lib/lp/code/model/tests/test_seriessourcepackagebranch.py
+++ b/lib/lp/code/model/tests/test_seriessourcepackagebranch.py
@@ -52,8 +52,7 @@ class TestSeriesSourcePackageBranchSet(TestCaseWithFactory):
 
         links = self.link_set.findForDistributionSourcePackage(
             distro_source_package)
-        self.assertEqual(
-            sorted([b1, b2]), sorted([link.branch for link in links]))
+        self.assertContentEqual([b1, b2], [link.branch for link in links])
 
     def test_delete(self):
         # SeriesSourcePackageBranchSet.delete removes the link between a
@@ -75,5 +74,5 @@ class TestSeriesSourcePackageBranchSet(TestCaseWithFactory):
             branch_updates, branch_updates.owner)
         self.link_set.delete(sourcepackage, PackagePublishingPocket.UPDATES)
         links = self.link_set.findForSourcePackage(sourcepackage)
-        self.assertEqual(
-            sorted([branch_release]), sorted([link.branch for link in links]))
+        self.assertContentEqual(
+            [branch_release], [link.branch for link in links])
diff --git a/lib/lp/code/model/tests/test_sourcepackagerecipe.py b/lib/lp/code/model/tests/test_sourcepackagerecipe.py
index fd47336..514521f 100644
--- a/lib/lp/code/model/tests/test_sourcepackagerecipe.py
+++ b/lib/lp/code/model/tests/test_sourcepackagerecipe.py
@@ -290,9 +290,9 @@ class TestSourcePackageRecipeMixin:
         # If a recipe links to more than one branch, getReferencedBranches()
         # returns all of them.
         sp_recipe, [branch1, branch2] = self.createSourcePackageRecipe()
-        self.assertEqual(
-            sorted([self.getRepository(branch1), self.getRepository(branch2)]),
-            sorted(sp_recipe.getReferencedBranches()))
+        self.assertContentEqual(
+            [self.getRepository(branch1), self.getRepository(branch2)],
+            sp_recipe.getReferencedBranches())
 
     def test_preLoadReferencedBranches(self):
         sp_recipe, unused = self.createSourcePackageRecipe()
@@ -302,9 +302,8 @@ class TestSourcePackageRecipeMixin:
         referenced_branches = sp_recipe.getReferencedBranches()
         clear_property_cache(recipe_data)
         SourcePackageRecipeData.preLoadReferencedBranches([recipe_data])
-        self.assertEqual(
-            sorted(referenced_branches),
-            sorted(sp_recipe.getReferencedBranches()))
+        self.assertContentEqual(
+            referenced_branches, sp_recipe.getReferencedBranches())
 
     def test_random_user_cant_edit(self):
         # An arbitrary user can't set attributes.
diff --git a/lib/lp/registry/tests/test_person.py b/lib/lp/registry/tests/test_person.py
index f919f3c..de9e9a0 100644
--- a/lib/lp/registry/tests/test_person.py
+++ b/lib/lp/registry/tests/test_person.py
@@ -245,25 +245,25 @@ class TestPersonTeams(TestCaseWithFactory):
         # still be retrieved by 'api_all_members'.  See bug #680461.
         self.factory.makeArchive(
             owner=self.user, purpose=ArchivePurpose.PARTNER)
-        expected_members = sorted([self.user, self.a_team.teamowner])
-        retrieved_members = sorted(list(self.a_team.api_all_members))
-        self.assertEqual(expected_members, retrieved_members)
+        expected_members = [self.user, self.a_team.teamowner]
+        retrieved_members = list(self.a_team.api_all_members)
+        self.assertContentEqual(expected_members, retrieved_members)
 
     def test_inTeam_person_no_archive(self):
         # If a person has no archive that person should still be retrieved by
         # 'api_all_members'.
-        expected_members = sorted([self.user, self.a_team.teamowner])
-        retrieved_members = sorted(list(self.a_team.api_all_members))
-        self.assertEqual(expected_members, retrieved_members)
+        expected_members = [self.user, self.a_team.teamowner]
+        retrieved_members = list(self.a_team.api_all_members)
+        self.assertContentEqual(expected_members, retrieved_members)
 
     def test_inTeam_person_ppa_archive(self):
         # If a person has a PPA that person should still be retrieved by
         # 'api_all_members'.
         self.factory.makeArchive(
             owner=self.user, purpose=ArchivePurpose.PPA)
-        expected_members = sorted([self.user, self.a_team.teamowner])
-        retrieved_members = sorted(list(self.a_team.api_all_members))
-        self.assertEqual(expected_members, retrieved_members)
+        expected_members = [self.user, self.a_team.teamowner]
+        retrieved_members = list(self.a_team.api_all_members)
+        self.assertContentEqual(expected_members, retrieved_members)
 
     def test_getOwnedTeams(self):
         # The iterator contains the teams that person owns, regardless of
diff --git a/lib/lp/registry/tests/test_projectgroup.py b/lib/lp/registry/tests/test_projectgroup.py
index 35f059b..9edca88 100644
--- a/lib/lp/registry/tests/test_projectgroup.py
+++ b/lib/lp/registry/tests/test_projectgroup.py
@@ -94,16 +94,16 @@ class ProjectGroupSearchTestCase(TestCaseWithFactory):
         results = self.projectgroupset.search(
             text="zazzle", search_products=False)
         self.assertEqual(2, results.count())
-        expected = sorted([self.projectgroup1, self.projectgroup2])
-        self.assertEqual(expected, sorted(results))
+        self.assertContentEqual(
+            [self.projectgroup1, self.projectgroup2], results)
 
     def testSearchDifferingCaseMatch(self):
         # Search for a matching string with a different case.
         results = self.projectgroupset.search(
             text="Zazzle", search_products=False)
         self.assertEqual(2, results.count())
-        expected = sorted([self.projectgroup1, self.projectgroup2])
-        self.assertEqual(expected, sorted(results))
+        self.assertContentEqual(
+            [self.projectgroup1, self.projectgroup2], results)
 
     def testProductSearchNoMatch(self):
         # Search for only project group even if a product matches.
diff --git a/lib/lp/soyuz/tests/test_binarypackagename.py b/lib/lp/soyuz/tests/test_binarypackagename.py
index cd99b96..4c28abc 100644
--- a/lib/lp/soyuz/tests/test_binarypackagename.py
+++ b/lib/lp/soyuz/tests/test_binarypackagename.py
@@ -89,11 +89,11 @@ class TestBinaryPackageNameSet(TestCaseWithFactory):
 
     def test_getNotNewByNames_excludes_unpublished(self):
         names, distroarchseries, archives = self.createPublishingRecords()
-        self.assertEqual(
-            sorted([names[0], names[1]]),
-            sorted(self.name_set.getNotNewByNames(
+        self.assertContentEqual(
+            [names[0], names[1]],
+            self.name_set.getNotNewByNames(
                 [name.id for name in names], distroarchseries.distroseries,
-                [archive.id for archive in archives])))
+                [archive.id for archive in archives]))
 
     def test_getNotNewByNames_excludes_by_status(self):
         names, distroarchseries, archives = self.createPublishingRecords()
@@ -103,11 +103,11 @@ class TestBinaryPackageNameSet(TestCaseWithFactory):
             binarypackagerelease=bpr,
             status=PackagePublishingStatus.DELETED,
             archive=archives[0], distroarchseries=distroarchseries)
-        self.assertEqual(
-            sorted([names[0], names[1]]),
-            sorted(self.name_set.getNotNewByNames(
+        self.assertContentEqual(
+            [names[0], names[1]],
+            self.name_set.getNotNewByNames(
                 [name.id for name in names], distroarchseries.distroseries,
-                [archive.id for archive in archives])))
+                [archive.id for archive in archives]))
 
     def test_getNotNewByNames_excludes_by_name_id(self):
         names, distroarchseries, archives = self.createPublishingRecords()
@@ -126,11 +126,11 @@ class TestBinaryPackageNameSet(TestCaseWithFactory):
             binarypackagerelease=bpr,
             status=PackagePublishingStatus.PUBLISHED,
             archive=archives[0])
-        self.assertEqual(
-            sorted([names[0], names[1]]),
-            sorted(self.name_set.getNotNewByNames(
+        self.assertContentEqual(
+            [names[0], names[1]],
+            self.name_set.getNotNewByNames(
                 [name.id for name in names], distroarchseries.distroseries,
-                [archive.id for archive in archives])))
+                [archive.id for archive in archives]))
 
     def test_getNotNewByNames_excludes_by_archive(self):
         names, distroarchseries, archives = self.createPublishingRecords()
diff --git a/lib/lp/soyuz/tests/test_packageset.py b/lib/lp/soyuz/tests/test_packageset.py
index abdce1f..8ac6777 100644
--- a/lib/lp/soyuz/tests/test_packageset.py
+++ b/lib/lp/soyuz/tests/test_packageset.py
@@ -180,9 +180,9 @@ class TestPackagesetSet(TestCaseWithFactory):
     def test_sets_including_source(self):
         # Returns the list of sets including a source package
         parent, child, package = self.buildSimpleHierarchy()
-        self.assertEqual(
-            sorted(self.ps_set.setsIncludingSource(package)),
-            sorted((parent, child)))
+        self.assertContentEqual(
+            self.ps_set.setsIncludingSource(package),
+            (parent, child))
 
         # And can be limited to direct inclusion
         result = self.ps_set.setsIncludingSource(
@@ -196,7 +196,7 @@ class TestPackagesetSet(TestCaseWithFactory):
         parent, child, package = self.buildSimpleHierarchy(series)
         result = self.ps_set.setsIncludingSource(
             package, distroseries=series)
-        self.assertEqual(sorted(result), sorted([parent, child]))
+        self.assertContentEqual(result, [parent, child])
 
     def test_sets_including_source_different_series(self):
         # searches are limited to one series
@@ -209,9 +209,9 @@ class TestPackagesetSet(TestCaseWithFactory):
     def test_sets_including_source_by_name(self):
         # Returns the list osf sets including a source package
         parent, child, package = self.buildSimpleHierarchy()
-        self.assertEqual(
-            sorted(self.ps_set.setsIncludingSource(package.name)),
-            sorted([parent, child]))
+        self.assertContentEqual(
+            self.ps_set.setsIncludingSource(package.name),
+            [parent, child])
 
     def test_sets_including_source_unknown_name(self):
         # A non-existent package name will throw an exception
@@ -415,29 +415,25 @@ class TestPackageset(TestCaseWithFactory):
     def test_sources_included(self):
         # Lists the source packages included in a set
         packageset, packages = self.buildSet()
-        self.assertEqual(
-            sorted(packageset.sourcesIncluded()), sorted(packages))
+        self.assertContentEqual(packageset.sourcesIncluded(), packages)
 
     def test_get_sources_included(self):
         # Lists the names of source packages included in a set
         packageset, packages = self.buildSet()
-        self.assertEqual(
-            sorted(packageset.getSourcesIncluded()),
-            sorted(p.name for p in packages))
+        self.assertContentEqual(
+            packageset.getSourcesIncluded(), [p.name for p in packages])
 
     def test_sources_included_indirect(self):
         # sourcesIncluded traverses the set tree, by default
         packageset1, packages1 = self.buildSet()
         packageset2, packages2 = self.buildSet()
         packageset1.add((packageset2,))
-        self.assertEqual(
-            sorted(packageset1.sourcesIncluded()),
-            sorted(packages1 + packages2))
+        self.assertContentEqual(
+            packageset1.sourcesIncluded(), packages1 + packages2)
 
         # direct_inclusion disables traversal
-        self.assertEqual(
-            sorted(packageset1.sourcesIncluded(direct_inclusion=True)),
-            sorted(packages1))
+        self.assertContentEqual(
+            packageset1.sourcesIncluded(direct_inclusion=True), packages1)
 
     def test_sources_multiply_included(self):
         # Source packages included in multiple packagesets in a tree are only
@@ -446,12 +442,11 @@ class TestPackageset(TestCaseWithFactory):
         packageset2, packages2 = self.buildSet(5)
         packageset1.add(packages2[:2])
         packageset1.add((packageset2,))
-        self.assertEqual(
-            sorted(packageset1.sourcesIncluded(direct_inclusion=True)),
-            sorted(packages1 + packages2[:2]))
-        self.assertEqual(
-            sorted(packageset1.sourcesIncluded()),
-            sorted(packages1 + packages2))
+        self.assertContentEqual(
+            packageset1.sourcesIncluded(direct_inclusion=True),
+            packages1 + packages2[:2])
+        self.assertContentEqual(
+            packageset1.sourcesIncluded(), packages1 + packages2)
 
     def test_is_source_included(self):
         # Test if a source package name is included in a set
@@ -481,22 +476,20 @@ class TestPackageset(TestCaseWithFactory):
         # Adding source packages to a package set repeatedly has no effect
         packageset, packages = self.buildSet()
         packageset.add(packages)
-        self.assertEqual(
-            sorted(packageset.sourcesIncluded()), sorted(packages))
+        self.assertContentEqual(packageset.sourcesIncluded(), packages)
 
     def test_remove_sources(self):
         # Source packages can be removed from a set
         packageset, packages = self.buildSet(5)
         packageset.remove(packages[:2])
-        self.assertEqual(
-            sorted(packageset.sourcesIncluded()), sorted(packages[2:]))
+        self.assertContentEqual(packageset.sourcesIncluded(), packages[2:])
 
     def test_remove_non_preset_sources(self):
         # Trying to remove source packages that are *not* in the set, has no
         # effect.
         packageset, packages = self.buildSet()
         packageset.remove([self.factory.makeSourcePackageName()])
-        self.assertTrue(sorted(packageset.sourcesIncluded()), sorted(packages))
+        self.assertContentEqual(packageset.sourcesIncluded(), packages)
 
     def test_sets_included(self):
         # Returns the sets included in a set
@@ -505,8 +498,7 @@ class TestPackageset(TestCaseWithFactory):
         parent.add((child,))
         grandchild = self.factory.makePackageset()
         child.add((grandchild,))
-        self.assertEqual(
-            sorted(parent.setsIncluded()), sorted([child, grandchild]))
+        self.assertContentEqual(parent.setsIncluded(), [child, grandchild])
         self.assertEqual(
             list(parent.setsIncluded(direct_inclusion=True)), [child])
 
@@ -520,8 +512,8 @@ class TestPackageset(TestCaseWithFactory):
         grandchild = self.factory.makePackageset()
         child.add((grandchild,))
         child2.add((grandchild,))
-        self.assertEqual(
-            sorted(parent.setsIncluded()), sorted([child, child2, grandchild]))
+        self.assertContentEqual(
+            parent.setsIncluded(), [child, child2, grandchild])
 
     def test_sets_included_by(self):
         # Returns the set of sets including a set
@@ -530,8 +522,7 @@ class TestPackageset(TestCaseWithFactory):
         parent.add((child,))
         grandchild = self.factory.makePackageset()
         child.add((grandchild,))
-        self.assertEqual(
-            sorted(grandchild.setsIncludedBy()), sorted([child, parent]))
+        self.assertContentEqual(grandchild.setsIncludedBy(), [child, parent])
         self.assertEqual(
             list(grandchild.setsIncludedBy(direct_inclusion=True)), [child])
 
@@ -541,8 +532,7 @@ class TestPackageset(TestCaseWithFactory):
         child = self.factory.makePackageset()
         child2 = self.factory.makePackageset()
         parent.add((child, child2))
-        self.assertEqual(
-            sorted(parent.setsIncluded()), sorted([child, child2]))
+        self.assertContentEqual(parent.setsIncluded(), [child, child2])
         parent.remove((child,))
         self.assertEqual(list(parent.setsIncluded()), [child2])
 
@@ -553,11 +543,9 @@ class TestPackageset(TestCaseWithFactory):
         grandchild = self.factory.makePackageset()
         parent.add((child,))
         child.add((grandchild,))
-        self.assertEqual(
-            sorted(parent.setsIncluded()), sorted([child, grandchild]))
+        self.assertContentEqual(parent.setsIncluded(), [child, grandchild])
         parent.remove((grandchild,))
-        self.assertEqual(
-            sorted(parent.setsIncluded()), sorted([child, grandchild]))
+        self.assertContentEqual(parent.setsIncluded(), [child, grandchild])
 
     def test_sources_shared_by(self):
         # Lists the source packages shared between two packagesets
@@ -567,9 +555,8 @@ class TestPackageset(TestCaseWithFactory):
 
         pset1.add(pkgs2[:2])
         pset2.add(pkgs1[:2])
-        self.assertEqual(
-            sorted(pset1.sourcesSharedBy(pset2)),
-            sorted(pkgs1[:2] + pkgs2[:2]))
+        self.assertContentEqual(
+            pset1.sourcesSharedBy(pset2), pkgs1[:2] + pkgs2[:2])
 
     def test_get_sources_shared_by(self):
         # List the names of source packages shared between two packagesets
@@ -579,9 +566,9 @@ class TestPackageset(TestCaseWithFactory):
 
         pset1.add(pkgs2[:2])
         pset2.add(pkgs1[:2])
-        self.assertEqual(
-            sorted(pset1.getSourcesSharedBy(pset2)),
-            sorted(p.name for p in (pkgs1[:2] + pkgs2[:2])))
+        self.assertContentEqual(
+            pset1.getSourcesSharedBy(pset2),
+            [p.name for p in (pkgs1[:2] + pkgs2[:2])])
 
     def test_sources_shared_by_subset(self):
         # sourcesSharedBy takes subsets into account, unless told not to
@@ -590,7 +577,7 @@ class TestPackageset(TestCaseWithFactory):
         self.assertTrue(pset1.sourcesSharedBy(pset2).is_empty())
 
         pset1.add((pset2,))
-        self.assertEqual(sorted(pset1.sourcesSharedBy(pset2)), sorted(pkgs2))
+        self.assertContentEqual(pset1.sourcesSharedBy(pset2), pkgs2)
         self.assertTrue(
             pset1.sourcesSharedBy(pset2, direct_inclusion=True).is_empty())
 
@@ -603,50 +590,47 @@ class TestPackageset(TestCaseWithFactory):
 
         pset1.add(pkgs2[:2] + pkgs3)
         pset2.add(pkgs1[:2] + [pset3])
-        self.assertEqual(
-            sorted(pset1.sourcesSharedBy(pset2)),
-            sorted(pkgs1[:2] + pkgs2[:2] + pkgs3))
-        self.assertEqual(
-            sorted(pset1.sourcesSharedBy(pset2)),
-            sorted(pset2.sourcesSharedBy(pset1)))
+        self.assertContentEqual(
+            pset1.sourcesSharedBy(pset2),
+            pkgs1[:2] + pkgs2[:2] + pkgs3)
+        self.assertContentEqual(
+            pset1.sourcesSharedBy(pset2),
+            pset2.sourcesSharedBy(pset1))
 
     def test_sources_not_shared_by(self):
         # Lists source packages in the first set, but not the second
         pset1, pkgs1 = self.buildSet(5)
         pset2, pkgs2 = self.buildSet(5)
-        self.assertEqual(
-            sorted(pset1.sourcesNotSharedBy(pset2)), sorted(pkgs1))
+        self.assertContentEqual(pset1.sourcesNotSharedBy(pset2), pkgs1)
         pset1.add(pkgs2[:2])
         pset2.add(pkgs1[:2])
-        self.assertEqual(
-            sorted(pset1.sourcesNotSharedBy(pset2)), sorted(pkgs1[2:]))
+        self.assertContentEqual(pset1.sourcesNotSharedBy(pset2), pkgs1[2:])
 
     def test_get_sources_not_shared_by(self):
         # List the names of source packages in the first set, but not the
         # second
         pset1, pkgs1 = self.buildSet(5)
         pset2, pkgs2 = self.buildSet(5)
-        self.assertEqual(
-            sorted(pset1.getSourcesNotSharedBy(pset2)),
-            sorted(p.name for p in pkgs1))
+        self.assertContentEqual(
+            pset1.getSourcesNotSharedBy(pset2),
+            [p.name for p in pkgs1])
 
         pset1.add(pkgs2[:2])
         pset2.add(pkgs1[:2])
-        self.assertEqual(
-            sorted(pset1.getSourcesNotSharedBy(pset2)),
-            sorted(p.name for p in pkgs1[2:]))
+        self.assertContentEqual(
+            pset1.getSourcesNotSharedBy(pset2),
+            [p.name for p in pkgs1[2:]])
 
     def test_sources_not_shared_by_subset(self):
         # sourcesNotSharedBy takes subsets into account, unless told not to
         pset1, pkgs1 = self.buildSet()
         pset2, pkgs2 = self.buildSet()
-        self.assertTrue(sorted(pset1.sourcesNotSharedBy(pset2)), sorted(pkgs1))
+        self.assertContentEqual(pset1.sourcesNotSharedBy(pset2), pkgs1)
 
         pset2.add((pset1,))
         self.assertTrue(pset1.sourcesNotSharedBy(pset2).is_empty())
-        self.assertTrue(
-            sorted(pset1.sourcesNotSharedBy(pset2, direct_inclusion=True)),
-            sorted(pkgs1))
+        self.assertContentEqual(
+            pset1.sourcesNotSharedBy(pset2, direct_inclusion=True), pkgs1)
 
     def test_add_unknown_name(self):
         # Adding an unknown package name will raise an error
@@ -907,10 +891,10 @@ class TestArchivePermissionSet(TestCaseWithFactory):
         explicit_child = self.ap_set.newPackagesetUploader(
             self.archive, self.person, child, True)
 
-        self.assertEqual(
-            sorted(self.ap_set.uploadersForPackageset(
-                self.archive, child, direct_permissions=False)),
-            sorted((implicit_parent, explicit_child)))
+        self.assertContentEqual(
+            self.ap_set.uploadersForPackageset(
+                self.archive, child, direct_permissions=False),
+            (implicit_parent, explicit_child))
 
     def test_uploaders_for_packageset_subpackagesets_removed(self):
         # archive permissions cease to apply to removed child packagesets