Merge ~cjwatson/launchpad:py3-more-assertContentEqual into launchpad:master
- Git
- lp:~cjwatson/launchpad
- py3-more-assertContentEqual
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | a31a23f9c267c1b62f0ce05f815e729901d09567 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:py3-more-assertContentEqual |
Merge into: | launchpad:master |
Diff against target: |
1033 lines (+185/-235) 12 files modified
lib/lp/blueprints/model/tests/test_specification.py (+12/-18) lib/lp/bugs/model/tests/test_bugtask.py (+2/-4) lib/lp/code/model/tests/test_branchcollection.py (+40/-55) lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py (+1/-3) lib/lp/code/model/tests/test_gitcollection.py (+39/-45) lib/lp/code/model/tests/test_revisioncache.py (+2/-3) lib/lp/code/model/tests/test_seriessourcepackagebranch.py (+3/-4) lib/lp/code/model/tests/test_sourcepackagerecipe.py (+5/-6) lib/lp/registry/tests/test_person.py (+9/-9) lib/lp/registry/tests/test_projectgroup.py (+4/-4) lib/lp/soyuz/tests/test_binarypackagename.py (+12/-12) lib/lp/soyuz/tests/test_packageset.py (+56/-72) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cristian Gonzalez (community) | Approve | ||
Review via email: mp+396563@code.launchpad.net |
Commit message
Use assertContentEq
Description of the change
This works better on Python 3, where model instances aren't orderable.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/blueprints/model/tests/test_specification.py b/lib/lp/blueprints/model/tests/test_specification.py |
2 | index b9afaeb..4264e9f 100644 |
3 | --- a/lib/lp/blueprints/model/tests/test_specification.py |
4 | +++ b/lib/lp/blueprints/model/tests/test_specification.py |
5 | @@ -73,12 +73,10 @@ class TestSpecificationDependencies(TestCaseWithFactory): |
6 | do_next.createDependency(do_first) |
7 | do_last = self.factory.makeBlueprint() |
8 | do_last.createDependency(do_next) |
9 | - self.assertThat(sorted(do_first.getBlockedSpecs()), Equals([do_next])) |
10 | - self.assertThat( |
11 | - sorted(do_first.all_blocked()), Equals(sorted([do_next, do_last]))) |
12 | - self.assertThat(sorted(do_last.getDependencies()), Equals([do_next])) |
13 | - self.assertThat( |
14 | - sorted(do_last.all_deps()), Equals(sorted([do_first, do_next]))) |
15 | + self.assertContentEqual([do_next], do_first.getBlockedSpecs()) |
16 | + self.assertContentEqual([do_next, do_last], do_first.all_blocked()) |
17 | + self.assertContentEqual([do_next], do_last.getDependencies()) |
18 | + self.assertContentEqual([do_first, do_next], do_last.all_deps()) |
19 | |
20 | def test_diamond_dependency(self): |
21 | # do_first |
22 | @@ -94,18 +92,14 @@ class TestSpecificationDependencies(TestCaseWithFactory): |
23 | do_last = self.factory.makeBlueprint() |
24 | do_last.createDependency(do_next_lhs) |
25 | do_last.createDependency(do_next_rhs) |
26 | - self.assertThat( |
27 | - sorted(do_first.getBlockedSpecs()), |
28 | - Equals(sorted([do_next_lhs, do_next_rhs]))) |
29 | - self.assertThat( |
30 | - sorted(do_first.all_blocked()), |
31 | - Equals(sorted([do_next_lhs, do_next_rhs, do_last]))) |
32 | - self.assertThat( |
33 | - sorted(do_last.getDependencies()), |
34 | - Equals(sorted([do_next_lhs, do_next_rhs]))) |
35 | - self.assertThat( |
36 | - sorted(do_last.all_deps()), |
37 | - Equals(sorted([do_first, do_next_lhs, do_next_rhs]))) |
38 | + self.assertContentEqual( |
39 | + [do_next_lhs, do_next_rhs], do_first.getBlockedSpecs()) |
40 | + self.assertContentEqual( |
41 | + [do_next_lhs, do_next_rhs, do_last], do_first.all_blocked()) |
42 | + self.assertContentEqual( |
43 | + [do_next_lhs, do_next_rhs], do_last.getDependencies()) |
44 | + self.assertContentEqual( |
45 | + [do_first, do_next_lhs, do_next_rhs], do_last.all_deps()) |
46 | |
47 | def test_all_deps_filters(self): |
48 | # all_deps, when provided a user, shows only the dependencies the user |
49 | diff --git a/lib/lp/bugs/model/tests/test_bugtask.py b/lib/lp/bugs/model/tests/test_bugtask.py |
50 | index 7466f7e..ec8c2e1 100644 |
51 | --- a/lib/lp/bugs/model/tests/test_bugtask.py |
52 | +++ b/lib/lp/bugs/model/tests/test_bugtask.py |
53 | @@ -1589,11 +1589,9 @@ class TestBugTaskMilestones(TestCaseWithFactory): |
54 | self.product_bug.default_bugtask, |
55 | self.distribution_bug.default_bugtask, |
56 | ] |
57 | - milestones = sorted( |
58 | + self.assertContentEqual( |
59 | + [self.product_milestone, self.distribution_milestone], |
60 | self.bugtaskset.getBugTaskTargetMilestones(tasks)) |
61 | - self.assertEqual( |
62 | - sorted([self.product_milestone, self.distribution_milestone]), |
63 | - milestones) |
64 | |
65 | |
66 | class TestConjoinedBugTasks(TestCaseWithFactory): |
67 | diff --git a/lib/lp/code/model/tests/test_branchcollection.py b/lib/lp/code/model/tests/test_branchcollection.py |
68 | index 35fce20..b02a942 100644 |
69 | --- a/lib/lp/code/model/tests/test_branchcollection.py |
70 | +++ b/lib/lp/code/model/tests/test_branchcollection.py |
71 | @@ -264,10 +264,9 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
72 | branch_a = self.factory.makeProductBranch(product=aardvark) |
73 | branch_b = self.factory.makeProductBranch(product=badger) |
74 | branch_c = self.factory.makePersonalBranch() |
75 | - self.assertEqual( |
76 | - sorted([branch_a, branch_b, branch_c]), |
77 | - sorted(self.all_branches.getBranches() |
78 | - .order_by(Branch.target_suffix))) |
79 | + self.assertContentEqual( |
80 | + [branch_a, branch_b, branch_c], |
81 | + self.all_branches.getBranches().order_by(Branch.target_suffix)) |
82 | |
83 | def test_count_respects_visibleByUser_filter(self): |
84 | # IBranchCollection.count() returns the number of branches that |
85 | @@ -452,8 +451,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
86 | # And a product branch. |
87 | self.factory.makeProductBranch() |
88 | collection = self.all_branches.inDistribution(distro) |
89 | - self.assertEqual( |
90 | - sorted([branch, branch2]), sorted(collection.getBranches())) |
91 | + self.assertContentEqual([branch, branch2], collection.getBranches()) |
92 | |
93 | def test_in_distro_series(self): |
94 | # 'inDistroSeries' returns a new collection that only has branches |
95 | @@ -471,8 +469,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
96 | # And a product branch. |
97 | self.factory.makeProductBranch() |
98 | collection = self.all_branches.inDistroSeries(series_one) |
99 | - self.assertEqual( |
100 | - sorted([branch, branch2]), sorted(collection.getBranches())) |
101 | + self.assertContentEqual([branch, branch2], collection.getBranches()) |
102 | |
103 | def _makeOffical(self, branch, pocket): |
104 | registrant = branch.sourcepackage.distribution.owner |
105 | @@ -489,8 +486,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
106 | self.factory.makePackageBranch() |
107 | self.factory.makePackageBranch() |
108 | collection = self.all_branches.officialBranches() |
109 | - self.assertEqual( |
110 | - sorted([branch1, branch2]), sorted(collection.getBranches())) |
111 | + self.assertContentEqual([branch1, branch2], collection.getBranches()) |
112 | |
113 | def test_official_branches_pocket(self): |
114 | # If passed a pocket, `officialBranches` returns a new collection that |
115 | @@ -504,8 +500,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
116 | self.factory.makePackageBranch() |
117 | collection = self.all_branches.officialBranches( |
118 | PackagePublishingPocket.BACKPORTS) |
119 | - self.assertEqual( |
120 | - sorted([branch2]), sorted(collection.getBranches())) |
121 | + self.assertContentEqual([branch2], collection.getBranches()) |
122 | |
123 | def test_in_distribution_source_package(self): |
124 | # 'inDistributionSourcePackage' returns a new collection that only has |
125 | @@ -533,8 +528,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
126 | sourcepackagename=package, distribution=series_one.distribution) |
127 | collection = self.all_branches.inDistributionSourcePackage( |
128 | distro_source_package) |
129 | - self.assertEqual( |
130 | - sorted([branch, branch2]), sorted(collection.getBranches())) |
131 | + self.assertContentEqual([branch, branch2], collection.getBranches()) |
132 | |
133 | def test_withLifecycleStatus(self): |
134 | # 'withLifecycleStatus' returns a new collection that only has |
135 | @@ -550,9 +544,8 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
136 | collection = self.all_branches.withLifecycleStatus( |
137 | BranchLifecycleStatus.DEVELOPMENT, |
138 | BranchLifecycleStatus.MATURE) |
139 | - self.assertEqual( |
140 | - sorted([branch1, branch3, branch4]), |
141 | - sorted(collection.getBranches())) |
142 | + self.assertContentEqual( |
143 | + [branch1, branch3, branch4], collection.getBranches()) |
144 | |
145 | def test_withIds(self): |
146 | # 'withIds' returns a new collection that only has branches with the |
147 | @@ -562,9 +555,7 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
148 | self.factory.makeAnyBranch() |
149 | ids = [branch1.id, branch2.id] |
150 | collection = self.all_branches.withIds(*ids) |
151 | - self.assertEqual( |
152 | - sorted([branch1, branch2]), |
153 | - sorted(collection.getBranches())) |
154 | + self.assertContentEqual([branch1, branch2], collection.getBranches()) |
155 | |
156 | def test_registeredBy(self): |
157 | # 'registeredBy' returns a new collection that only has branches that |
158 | @@ -601,9 +592,9 @@ class TestBranchCollectionFilters(TestCaseWithFactory): |
159 | branch_type=BranchType.IMPORTED) |
160 | branches = self.all_branches.withBranchType( |
161 | BranchType.HOSTED, BranchType.MIRRORED) |
162 | - self.assertEqual( |
163 | - sorted([hosted_branch1, hosted_branch2, mirrored_branch]), |
164 | - sorted(branches.getBranches())) |
165 | + self.assertContentEqual( |
166 | + [hosted_branch1, hosted_branch2, mirrored_branch], |
167 | + branches.getBranches()) |
168 | |
169 | def test_scanned(self): |
170 | scanned_branch = self.factory.makeAnyBranch() |
171 | @@ -696,11 +687,11 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory): |
172 | def test_all_branches(self): |
173 | # Without the visibleByUser filter, all branches are in the |
174 | # collection. |
175 | - self.assertEqual( |
176 | - sorted([self.public_branch, self.private_branch1, |
177 | - self.private_branch2, self.public_stacked_on_branch, |
178 | - self.private_stacked_on_branch]), |
179 | - sorted(self.all_branches.getBranches())) |
180 | + self.assertContentEqual( |
181 | + [self.public_branch, self.private_branch1, |
182 | + self.private_branch2, self.public_stacked_on_branch, |
183 | + self.private_stacked_on_branch], |
184 | + self.all_branches.getBranches()) |
185 | |
186 | def test_anonymous_sees_only_public(self): |
187 | # Anonymous users can see only public branches. |
188 | @@ -727,16 +718,14 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory): |
189 | # branches. |
190 | owner = removeSecurityProxy(self.private_branch1).owner |
191 | branches = self.all_branches.visibleByUser(owner) |
192 | - self.assertEqual( |
193 | - sorted([self.public_branch, self.private_branch1]), |
194 | - sorted(branches.getBranches())) |
195 | + self.assertContentEqual( |
196 | + [self.public_branch, self.private_branch1], branches.getBranches()) |
197 | |
198 | def test_launchpad_services_sees_all(self): |
199 | # The LAUNCHPAD_SERVICES special user sees *everything*. |
200 | branches = self.all_branches.visibleByUser(LAUNCHPAD_SERVICES) |
201 | - self.assertEqual( |
202 | - sorted(self.all_branches.getBranches()), |
203 | - sorted(branches.getBranches())) |
204 | + self.assertContentEqual( |
205 | + self.all_branches.getBranches(), branches.getBranches()) |
206 | |
207 | def test_admins_see_all(self): |
208 | # Launchpad administrators see *everything*. |
209 | @@ -745,9 +734,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory): |
210 | getUtility(ILaunchpadCelebrities).admin) |
211 | admin_team.addMember(admin, admin_team.teamowner) |
212 | branches = self.all_branches.visibleByUser(admin) |
213 | - self.assertEqual( |
214 | - sorted(self.all_branches.getBranches()), |
215 | - sorted(branches.getBranches())) |
216 | + self.assertContentEqual( |
217 | + self.all_branches.getBranches(), branches.getBranches()) |
218 | |
219 | def test_subscribers_can_see_branches(self): |
220 | # A person subscribed to a branch can see it, even if it's private. |
221 | @@ -758,9 +746,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory): |
222 | CodeReviewNotificationLevel.NOEMAIL, |
223 | subscriber) |
224 | branches = self.all_branches.visibleByUser(subscriber) |
225 | - self.assertEqual( |
226 | - sorted([self.public_branch, self.private_branch1]), |
227 | - sorted(branches.getBranches())) |
228 | + self.assertContentEqual( |
229 | + [self.public_branch, self.private_branch1], branches.getBranches()) |
230 | |
231 | def test_subscribed_team_members_can_see_branches(self): |
232 | # A person in a team that is subscribed to a branch can see that |
233 | @@ -780,9 +767,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory): |
234 | # Members of the team can see the private branch that the team is |
235 | # subscribed to. |
236 | branches = self.all_branches.visibleByUser(team_owner) |
237 | - self.assertEqual( |
238 | - sorted([self.public_branch, private_branch]), |
239 | - sorted(branches.getBranches())) |
240 | + self.assertContentEqual( |
241 | + [self.public_branch, private_branch], branches.getBranches()) |
242 | |
243 | def test_private_teams_see_own_private_junk_branches(self): |
244 | # Private teams are given an acess grant to see their private +junk |
245 | @@ -804,9 +790,8 @@ class TestGenericBranchCollectionVisibleFilter(TestCaseWithFactory): |
246 | self.factory.makePersonalBranch( |
247 | information_type=InformationType.USERDATA) |
248 | branches = self.all_branches.visibleByUser(team) |
249 | - self.assertEqual( |
250 | - sorted([self.public_branch, personal_branch]), |
251 | - sorted(branches.getBranches())) |
252 | + self.assertContentEqual( |
253 | + [self.public_branch, personal_branch], branches.getBranches()) |
254 | |
255 | |
256 | class TestExtendedBranchRevisionDetails(TestCaseWithFactory): |
257 | @@ -856,7 +841,7 @@ class TestExtendedBranchRevisionDetails(TestCaseWithFactory): |
258 | |
259 | result = self.all_branches.getExtendedRevisionDetails( |
260 | branch.owner, branch_revisions) |
261 | - self.assertEqual(sorted(expected_rev_details), sorted(result)) |
262 | + self.assertContentEqual(expected_rev_details, result) |
263 | |
264 | def test_some_revisions_with_bugs(self): |
265 | branch = self.factory.makeBranch() |
266 | @@ -876,7 +861,7 @@ class TestExtendedBranchRevisionDetails(TestCaseWithFactory): |
267 | expected_rev_details[0]['linked_bugtasks'] = linked_bugtasks |
268 | result = self.all_branches.getExtendedRevisionDetails( |
269 | branch.owner, branch_revisions) |
270 | - self.assertEqual(sorted(expected_rev_details), sorted(result)) |
271 | + self.assertContentEqual(expected_rev_details, result) |
272 | |
273 | def test_some_revisions_with_private_bugs(self): |
274 | branch = self.factory.makeBranch() |
275 | @@ -903,7 +888,7 @@ class TestExtendedBranchRevisionDetails(TestCaseWithFactory): |
276 | person = self.factory.makePerson() |
277 | result = self.all_branches.getExtendedRevisionDetails( |
278 | person, branch_revisions) |
279 | - self.assertEqual(sorted(expected_rev_details), sorted(result)) |
280 | + self.assertContentEqual(expected_rev_details, result) |
281 | |
282 | |
283 | class TestBranchMergeProposals(TestCaseWithFactory): |
284 | @@ -967,7 +952,7 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
285 | target_branch=target, source_branch=branch3) |
286 | collection = self.all_branches.ownedBy(person) |
287 | proposals = collection.getMergeProposals() |
288 | - self.assertEqual(sorted([mp1, mp2]), sorted(proposals)) |
289 | + self.assertContentEqual([mp1, mp2], proposals) |
290 | |
291 | def test_preloading_for_previewdiff(self): |
292 | product = self.factory.makeProduct() |
293 | @@ -1020,10 +1005,10 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
294 | collection = self.all_branches |
295 | result = collection.getMergeProposals( |
296 | target_branch=target, merged_revnos=[123]) |
297 | - self.assertEqual(sorted([mp1, mp2]), sorted(result)) |
298 | + self.assertContentEqual([mp1, mp2], result) |
299 | result = collection.getMergeProposals( |
300 | target_branch=target, merged_revnos=[123, 321]) |
301 | - self.assertEqual(sorted([mp1, mp2, mp3]), sorted(result)) |
302 | + self.assertContentEqual([mp1, mp2, mp3], result) |
303 | |
304 | def test_target_branch_private(self): |
305 | # The target branch must be in the branch collection, as must the |
306 | @@ -1046,7 +1031,7 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
307 | proposals = self.all_branches.getMergeProposals( |
308 | [BranchMergeProposalStatus.WORK_IN_PROGRESS, |
309 | BranchMergeProposalStatus.NEEDS_REVIEW]) |
310 | - self.assertEqual(sorted([mp1, mp2]), sorted(proposals)) |
311 | + self.assertContentEqual([mp1, mp2], proposals) |
312 | |
313 | def test_status_restriction_with_product_filter(self): |
314 | # getMergeProposals returns the merge proposals with a particular |
315 | @@ -1270,7 +1255,7 @@ class TestSearch(TestCaseWithFactory): |
316 | branch2 = self.factory.makeAnyBranch(name='foo') |
317 | self.factory.makeAnyBranch() |
318 | search_results = self.collection.search('foo') |
319 | - self.assertEqual(sorted([branch1, branch2]), sorted(search_results)) |
320 | + self.assertContentEqual([branch1, branch2], search_results) |
321 | |
322 | def test_match_against_unique_name(self): |
323 | branch = self.factory.makeAnyBranch(name='fooa') |
324 | @@ -1285,7 +1270,7 @@ class TestSearch(TestCaseWithFactory): |
325 | branch2 = self.factory.makeAnyBranch(name='foob') |
326 | self.factory.makeAnyBranch() |
327 | search_results = self.collection.search('foo') |
328 | - self.assertEqual(sorted([branch1, branch2]), sorted(search_results)) |
329 | + self.assertContentEqual([branch1, branch2], search_results) |
330 | |
331 | def test_match_ignores_case(self): |
332 | branch = self.factory.makeAnyBranch(name='foobar') |
333 | diff --git a/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py b/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py |
334 | index c16d36e..debec5e 100644 |
335 | --- a/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py |
336 | +++ b/lib/lp/code/model/tests/test_branchlistingqueryoptimiser.py |
337 | @@ -131,9 +131,7 @@ class TestGetOfficialSourcePackageLinksForBranches(TestCaseWithFactory): |
338 | make_linked_package_branch(self.factory) |
339 | links = (BranchListingQueryOptimiser. |
340 | getOfficialSourcePackageLinksForBranches([b1.id, b2.id])) |
341 | - self.assertEqual( |
342 | - sorted([b1, b2]), |
343 | - sorted([link.branch for link in links])) |
344 | + self.assertContentEqual([b1, b2], [link.branch for link in links]) |
345 | |
346 | def test_objects_loaded(self): |
347 | # Traversing through the source package and the distribution should |
348 | diff --git a/lib/lp/code/model/tests/test_gitcollection.py b/lib/lp/code/model/tests/test_gitcollection.py |
349 | index 447fcb4..2c72590 100644 |
350 | --- a/lib/lp/code/model/tests/test_gitcollection.py |
351 | +++ b/lib/lp/code/model/tests/test_gitcollection.py |
352 | @@ -220,10 +220,10 @@ class TestGitCollectionFilters(TestCaseWithFactory): |
353 | person = self.factory.makePerson() |
354 | repository_c = self.factory.makeGitRepository( |
355 | owner=person, target=person) |
356 | - self.assertEqual( |
357 | - sorted([repository_a, repository_b, repository_c]), |
358 | - sorted(self.all_repositories.getRepositories() |
359 | - .order_by(GitRepository.name))) |
360 | + self.assertContentEqual( |
361 | + [repository_a, repository_b, repository_c], |
362 | + self.all_repositories.getRepositories() |
363 | + .order_by(GitRepository.name)) |
364 | |
365 | def test_count_respects_visibleByUser_filter(self): |
366 | # IGitCollection.count() returns the number of repositories that |
367 | @@ -393,9 +393,8 @@ class TestGitCollectionFilters(TestCaseWithFactory): |
368 | # And a project repository. |
369 | self.factory.makeGitRepository() |
370 | collection = self.all_repositories.inDistribution(distro) |
371 | - self.assertEqual( |
372 | - sorted([repository, repository2]), |
373 | - sorted(collection.getRepositories())) |
374 | + self.assertContentEqual( |
375 | + [repository, repository2], collection.getRepositories()) |
376 | |
377 | def test_in_distribution_source_package(self): |
378 | # 'inDistributionSourcePackage' returns a new collection that only |
379 | @@ -408,9 +407,8 @@ class TestGitCollectionFilters(TestCaseWithFactory): |
380 | self.factory.makeGitRepository(target=dsp_other_distro) |
381 | self.factory.makeGitRepository() |
382 | collection = self.all_repositories.inDistributionSourcePackage(dsp) |
383 | - self.assertEqual( |
384 | - sorted([repository, repository2]), |
385 | - sorted(collection.getRepositories())) |
386 | + self.assertContentEqual( |
387 | + [repository, repository2], collection.getRepositories()) |
388 | |
389 | def test_in_oci_project(self): |
390 | # 'inOCIProject' returns a new collection that only |
391 | @@ -422,9 +420,8 @@ class TestGitCollectionFilters(TestCaseWithFactory): |
392 | self.factory.makeGitRepository(target=ocip_other_distro) |
393 | self.factory.makeGitRepository() |
394 | collection = self.all_repositories.inOCIProject(ocip) |
395 | - self.assertEqual( |
396 | - sorted([repository, repository2]), |
397 | - sorted(collection.getRepositories())) |
398 | + self.assertContentEqual( |
399 | + [repository, repository2], collection.getRepositories()) |
400 | |
401 | def test_withIds(self): |
402 | # 'withIds' returns a new collection that only has repositories with |
403 | @@ -434,9 +431,8 @@ class TestGitCollectionFilters(TestCaseWithFactory): |
404 | self.factory.makeGitRepository() |
405 | ids = [repository1.id, repository2.id] |
406 | collection = self.all_repositories.withIds(*ids) |
407 | - self.assertEqual( |
408 | - sorted([repository1, repository2]), |
409 | - sorted(collection.getRepositories())) |
410 | + self.assertContentEqual( |
411 | + [repository1, repository2], collection.getRepositories()) |
412 | |
413 | def test_registeredBy(self): |
414 | # 'registeredBy' returns a new collection that only has repositories |
415 | @@ -538,7 +534,7 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
416 | target_ref=target, source_ref=ref3) |
417 | collection = self.all_repositories.ownedBy(person) |
418 | proposals = collection.getMergeProposals() |
419 | - self.assertEqual(sorted([mp1, mp2]), sorted(proposals)) |
420 | + self.assertContentEqual([mp1, mp2], proposals) |
421 | |
422 | def test_preloading_for_previewdiff(self): |
423 | project = self.factory.makeProduct() |
424 | @@ -615,7 +611,7 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
425 | proposals = self.all_repositories.getMergeProposals( |
426 | [BranchMergeProposalStatus.WORK_IN_PROGRESS, |
427 | BranchMergeProposalStatus.NEEDS_REVIEW]) |
428 | - self.assertEqual(sorted([mp1, mp2]), sorted(proposals)) |
429 | + self.assertContentEqual([mp1, mp2], proposals) |
430 | |
431 | def test_status_restriction_with_project_filter(self): |
432 | # getMergeProposals returns the merge proposals with a particular |
433 | @@ -648,7 +644,7 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
434 | self.factory.makeBranchMergeProposalForGit() |
435 | proposals = self.all_repositories.getMergeProposals( |
436 | target_repository=mp1.target_git_repository) |
437 | - self.assertEqual(sorted([mp1, mp2]), sorted(proposals)) |
438 | + self.assertContentEqual([mp1, mp2], proposals) |
439 | |
440 | def test_specifying_target_ref(self): |
441 | # If the target_repository and target_path are specified, only merge |
442 | @@ -671,7 +667,7 @@ class TestBranchMergeProposals(TestCaseWithFactory): |
443 | self.factory.makeBranchMergeProposalForGit() |
444 | proposals = self.all_repositories.getMergeProposals( |
445 | prerequisite_repository=ref1.repository) |
446 | - self.assertEqual(sorted([mp1, mp2]), sorted(proposals)) |
447 | + self.assertContentEqual([mp1, mp2], proposals) |
448 | |
449 | def test_specifying_prerequisite_ref(self): |
450 | # If the prerequisite_repository and prerequisite_path are |
451 | @@ -773,9 +769,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory): |
452 | def test_all_repositories(self): |
453 | # Without the visibleByUser filter, all repositories are in the |
454 | # collection. |
455 | - self.assertEqual( |
456 | - sorted([self.public_repository, self.private_repository]), |
457 | - sorted(self.all_repositories.getRepositories())) |
458 | + self.assertContentEqual( |
459 | + [self.public_repository, self.private_repository], |
460 | + self.all_repositories.getRepositories()) |
461 | |
462 | def test_anonymous_sees_only_public(self): |
463 | # Anonymous users can see only public repositories. |
464 | @@ -804,16 +800,16 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory): |
465 | # public repositories. |
466 | owner = removeSecurityProxy(self.private_repository).owner |
467 | repositories = self.all_repositories.visibleByUser(owner) |
468 | - self.assertEqual( |
469 | - sorted([self.public_repository, self.private_repository]), |
470 | - sorted(repositories.getRepositories())) |
471 | + self.assertContentEqual( |
472 | + [self.public_repository, self.private_repository], |
473 | + repositories.getRepositories()) |
474 | |
475 | def test_launchpad_services_sees_all(self): |
476 | # The LAUNCHPAD_SERVICES special user sees *everything*. |
477 | repositories = self.all_repositories.visibleByUser(LAUNCHPAD_SERVICES) |
478 | - self.assertEqual( |
479 | - sorted(self.all_repositories.getRepositories()), |
480 | - sorted(repositories.getRepositories())) |
481 | + self.assertContentEqual( |
482 | + self.all_repositories.getRepositories(), |
483 | + repositories.getRepositories()) |
484 | |
485 | def test_admins_see_all(self): |
486 | # Launchpad administrators see *everything*. |
487 | @@ -822,9 +818,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory): |
488 | getUtility(ILaunchpadCelebrities).admin) |
489 | admin_team.addMember(admin, admin_team.teamowner) |
490 | repositories = self.all_repositories.visibleByUser(admin) |
491 | - self.assertEqual( |
492 | - sorted(self.all_repositories.getRepositories()), |
493 | - sorted(repositories.getRepositories())) |
494 | + self.assertContentEqual( |
495 | + self.all_repositories.getRepositories(), |
496 | + repositories.getRepositories()) |
497 | |
498 | def test_subscribers_can_see_repositories(self): |
499 | # A person subscribed to a repository can see it, even if it's |
500 | @@ -836,9 +832,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory): |
501 | CodeReviewNotificationLevel.NOEMAIL, |
502 | subscriber) |
503 | repositories = self.all_repositories.visibleByUser(subscriber) |
504 | - self.assertEqual( |
505 | - sorted([self.public_repository, self.private_repository]), |
506 | - sorted(repositories.getRepositories())) |
507 | + self.assertContentEqual( |
508 | + [self.public_repository, self.private_repository], |
509 | + repositories.getRepositories()) |
510 | |
511 | def test_subscribed_team_members_can_see_repositories(self): |
512 | # A person in a team that is subscribed to a repository can see that |
513 | @@ -856,9 +852,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory): |
514 | # Members of the team can see the private repository that the team |
515 | # is subscribed to. |
516 | repositories = self.all_repositories.visibleByUser(team_owner) |
517 | - self.assertEqual( |
518 | - sorted([self.public_repository, self.private_repository]), |
519 | - sorted(repositories.getRepositories())) |
520 | + self.assertContentEqual( |
521 | + [self.public_repository, self.private_repository], |
522 | + repositories.getRepositories()) |
523 | |
524 | def test_private_teams_see_own_private_personal_repositories(self): |
525 | # Private teams are given an access grant to see their private |
526 | @@ -883,9 +879,9 @@ class TestGenericGitCollectionVisibleFilter(TestCaseWithFactory): |
527 | owner=other_person, target=other_person, |
528 | information_type=InformationType.USERDATA) |
529 | repositories = self.all_repositories.visibleByUser(team) |
530 | - self.assertEqual( |
531 | - sorted([self.public_repository, personal_repository]), |
532 | - sorted(repositories.getRepositories())) |
533 | + self.assertContentEqual( |
534 | + [self.public_repository, personal_repository], |
535 | + repositories.getRepositories()) |
536 | |
537 | |
538 | class TestSearch(TestCaseWithFactory): |
539 | @@ -993,8 +989,7 @@ class TestSearch(TestCaseWithFactory): |
540 | repository2 = self.factory.makeGitRepository(name='foo') |
541 | self.factory.makeGitRepository() |
542 | search_results = self.collection.search('foo') |
543 | - self.assertEqual( |
544 | - sorted([repository1, repository2]), sorted(search_results)) |
545 | + self.assertContentEqual([repository1, repository2], search_results) |
546 | |
547 | def disabled_test_match_against_unique_name(self): |
548 | # XXX cjwatson 2015-02-06: Disabled until the URL format settles |
549 | @@ -1011,8 +1006,7 @@ class TestSearch(TestCaseWithFactory): |
550 | repository2 = self.factory.makeGitRepository(name='foob') |
551 | self.factory.makeGitRepository() |
552 | search_results = self.collection.search('foo') |
553 | - self.assertEqual( |
554 | - sorted([repository1, repository2]), sorted(search_results)) |
555 | + self.assertContentEqual([repository1, repository2], search_results) |
556 | |
557 | def test_match_ignores_case(self): |
558 | repository = self.factory.makeGitRepository(name='foobar') |
559 | diff --git a/lib/lp/code/model/tests/test_revisioncache.py b/lib/lp/code/model/tests/test_revisioncache.py |
560 | index 2f5ea2d..9f531c3 100644 |
561 | --- a/lib/lp/code/model/tests/test_revisioncache.py |
562 | +++ b/lib/lp/code/model/tests/test_revisioncache.py |
563 | @@ -150,9 +150,8 @@ class TestRevisionCache(TestCaseWithFactory): |
564 | revision_collection): |
565 | # Check that the revisions returned from the revision collection match |
566 | # the expected revisions. |
567 | - self.assertEqual( |
568 | - sorted(expected_revisions), |
569 | - sorted(revision_collection.getRevisions())) |
570 | + self.assertContentEqual( |
571 | + expected_revisions, revision_collection.getRevisions()) |
572 | |
573 | def test_private_revisions(self): |
574 | # Private flags are honoured when only requesting public revisions. |
575 | diff --git a/lib/lp/code/model/tests/test_seriessourcepackagebranch.py b/lib/lp/code/model/tests/test_seriessourcepackagebranch.py |
576 | index 0721868..b03f860 100644 |
577 | --- a/lib/lp/code/model/tests/test_seriessourcepackagebranch.py |
578 | +++ b/lib/lp/code/model/tests/test_seriessourcepackagebranch.py |
579 | @@ -52,8 +52,7 @@ class TestSeriesSourcePackageBranchSet(TestCaseWithFactory): |
580 | |
581 | links = self.link_set.findForDistributionSourcePackage( |
582 | distro_source_package) |
583 | - self.assertEqual( |
584 | - sorted([b1, b2]), sorted([link.branch for link in links])) |
585 | + self.assertContentEqual([b1, b2], [link.branch for link in links]) |
586 | |
587 | def test_delete(self): |
588 | # SeriesSourcePackageBranchSet.delete removes the link between a |
589 | @@ -75,5 +74,5 @@ class TestSeriesSourcePackageBranchSet(TestCaseWithFactory): |
590 | branch_updates, branch_updates.owner) |
591 | self.link_set.delete(sourcepackage, PackagePublishingPocket.UPDATES) |
592 | links = self.link_set.findForSourcePackage(sourcepackage) |
593 | - self.assertEqual( |
594 | - sorted([branch_release]), sorted([link.branch for link in links])) |
595 | + self.assertContentEqual( |
596 | + [branch_release], [link.branch for link in links]) |
597 | diff --git a/lib/lp/code/model/tests/test_sourcepackagerecipe.py b/lib/lp/code/model/tests/test_sourcepackagerecipe.py |
598 | index fd47336..514521f 100644 |
599 | --- a/lib/lp/code/model/tests/test_sourcepackagerecipe.py |
600 | +++ b/lib/lp/code/model/tests/test_sourcepackagerecipe.py |
601 | @@ -290,9 +290,9 @@ class TestSourcePackageRecipeMixin: |
602 | # If a recipe links to more than one branch, getReferencedBranches() |
603 | # returns all of them. |
604 | sp_recipe, [branch1, branch2] = self.createSourcePackageRecipe() |
605 | - self.assertEqual( |
606 | - sorted([self.getRepository(branch1), self.getRepository(branch2)]), |
607 | - sorted(sp_recipe.getReferencedBranches())) |
608 | + self.assertContentEqual( |
609 | + [self.getRepository(branch1), self.getRepository(branch2)], |
610 | + sp_recipe.getReferencedBranches()) |
611 | |
612 | def test_preLoadReferencedBranches(self): |
613 | sp_recipe, unused = self.createSourcePackageRecipe() |
614 | @@ -302,9 +302,8 @@ class TestSourcePackageRecipeMixin: |
615 | referenced_branches = sp_recipe.getReferencedBranches() |
616 | clear_property_cache(recipe_data) |
617 | SourcePackageRecipeData.preLoadReferencedBranches([recipe_data]) |
618 | - self.assertEqual( |
619 | - sorted(referenced_branches), |
620 | - sorted(sp_recipe.getReferencedBranches())) |
621 | + self.assertContentEqual( |
622 | + referenced_branches, sp_recipe.getReferencedBranches()) |
623 | |
624 | def test_random_user_cant_edit(self): |
625 | # An arbitrary user can't set attributes. |
626 | diff --git a/lib/lp/registry/tests/test_person.py b/lib/lp/registry/tests/test_person.py |
627 | index f919f3c..de9e9a0 100644 |
628 | --- a/lib/lp/registry/tests/test_person.py |
629 | +++ b/lib/lp/registry/tests/test_person.py |
630 | @@ -245,25 +245,25 @@ class TestPersonTeams(TestCaseWithFactory): |
631 | # still be retrieved by 'api_all_members'. See bug #680461. |
632 | self.factory.makeArchive( |
633 | owner=self.user, purpose=ArchivePurpose.PARTNER) |
634 | - expected_members = sorted([self.user, self.a_team.teamowner]) |
635 | - retrieved_members = sorted(list(self.a_team.api_all_members)) |
636 | - self.assertEqual(expected_members, retrieved_members) |
637 | + expected_members = [self.user, self.a_team.teamowner] |
638 | + retrieved_members = list(self.a_team.api_all_members) |
639 | + self.assertContentEqual(expected_members, retrieved_members) |
640 | |
641 | def test_inTeam_person_no_archive(self): |
642 | # If a person has no archive that person should still be retrieved by |
643 | # 'api_all_members'. |
644 | - expected_members = sorted([self.user, self.a_team.teamowner]) |
645 | - retrieved_members = sorted(list(self.a_team.api_all_members)) |
646 | - self.assertEqual(expected_members, retrieved_members) |
647 | + expected_members = [self.user, self.a_team.teamowner] |
648 | + retrieved_members = list(self.a_team.api_all_members) |
649 | + self.assertContentEqual(expected_members, retrieved_members) |
650 | |
651 | def test_inTeam_person_ppa_archive(self): |
652 | # If a person has a PPA that person should still be retrieved by |
653 | # 'api_all_members'. |
654 | self.factory.makeArchive( |
655 | owner=self.user, purpose=ArchivePurpose.PPA) |
656 | - expected_members = sorted([self.user, self.a_team.teamowner]) |
657 | - retrieved_members = sorted(list(self.a_team.api_all_members)) |
658 | - self.assertEqual(expected_members, retrieved_members) |
659 | + expected_members = [self.user, self.a_team.teamowner] |
660 | + retrieved_members = list(self.a_team.api_all_members) |
661 | + self.assertContentEqual(expected_members, retrieved_members) |
662 | |
663 | def test_getOwnedTeams(self): |
664 | # The iterator contains the teams that person owns, regardless of |
665 | diff --git a/lib/lp/registry/tests/test_projectgroup.py b/lib/lp/registry/tests/test_projectgroup.py |
666 | index 35f059b..9edca88 100644 |
667 | --- a/lib/lp/registry/tests/test_projectgroup.py |
668 | +++ b/lib/lp/registry/tests/test_projectgroup.py |
669 | @@ -94,16 +94,16 @@ class ProjectGroupSearchTestCase(TestCaseWithFactory): |
670 | results = self.projectgroupset.search( |
671 | text="zazzle", search_products=False) |
672 | self.assertEqual(2, results.count()) |
673 | - expected = sorted([self.projectgroup1, self.projectgroup2]) |
674 | - self.assertEqual(expected, sorted(results)) |
675 | + self.assertContentEqual( |
676 | + [self.projectgroup1, self.projectgroup2], results) |
677 | |
678 | def testSearchDifferingCaseMatch(self): |
679 | # Search for a matching string with a different case. |
680 | results = self.projectgroupset.search( |
681 | text="Zazzle", search_products=False) |
682 | self.assertEqual(2, results.count()) |
683 | - expected = sorted([self.projectgroup1, self.projectgroup2]) |
684 | - self.assertEqual(expected, sorted(results)) |
685 | + self.assertContentEqual( |
686 | + [self.projectgroup1, self.projectgroup2], results) |
687 | |
688 | def testProductSearchNoMatch(self): |
689 | # Search for only project group even if a product matches. |
690 | diff --git a/lib/lp/soyuz/tests/test_binarypackagename.py b/lib/lp/soyuz/tests/test_binarypackagename.py |
691 | index cd99b96..4c28abc 100644 |
692 | --- a/lib/lp/soyuz/tests/test_binarypackagename.py |
693 | +++ b/lib/lp/soyuz/tests/test_binarypackagename.py |
694 | @@ -89,11 +89,11 @@ class TestBinaryPackageNameSet(TestCaseWithFactory): |
695 | |
696 | def test_getNotNewByNames_excludes_unpublished(self): |
697 | names, distroarchseries, archives = self.createPublishingRecords() |
698 | - self.assertEqual( |
699 | - sorted([names[0], names[1]]), |
700 | - sorted(self.name_set.getNotNewByNames( |
701 | + self.assertContentEqual( |
702 | + [names[0], names[1]], |
703 | + self.name_set.getNotNewByNames( |
704 | [name.id for name in names], distroarchseries.distroseries, |
705 | - [archive.id for archive in archives]))) |
706 | + [archive.id for archive in archives])) |
707 | |
708 | def test_getNotNewByNames_excludes_by_status(self): |
709 | names, distroarchseries, archives = self.createPublishingRecords() |
710 | @@ -103,11 +103,11 @@ class TestBinaryPackageNameSet(TestCaseWithFactory): |
711 | binarypackagerelease=bpr, |
712 | status=PackagePublishingStatus.DELETED, |
713 | archive=archives[0], distroarchseries=distroarchseries) |
714 | - self.assertEqual( |
715 | - sorted([names[0], names[1]]), |
716 | - sorted(self.name_set.getNotNewByNames( |
717 | + self.assertContentEqual( |
718 | + [names[0], names[1]], |
719 | + self.name_set.getNotNewByNames( |
720 | [name.id for name in names], distroarchseries.distroseries, |
721 | - [archive.id for archive in archives]))) |
722 | + [archive.id for archive in archives])) |
723 | |
724 | def test_getNotNewByNames_excludes_by_name_id(self): |
725 | names, distroarchseries, archives = self.createPublishingRecords() |
726 | @@ -126,11 +126,11 @@ class TestBinaryPackageNameSet(TestCaseWithFactory): |
727 | binarypackagerelease=bpr, |
728 | status=PackagePublishingStatus.PUBLISHED, |
729 | archive=archives[0]) |
730 | - self.assertEqual( |
731 | - sorted([names[0], names[1]]), |
732 | - sorted(self.name_set.getNotNewByNames( |
733 | + self.assertContentEqual( |
734 | + [names[0], names[1]], |
735 | + self.name_set.getNotNewByNames( |
736 | [name.id for name in names], distroarchseries.distroseries, |
737 | - [archive.id for archive in archives]))) |
738 | + [archive.id for archive in archives])) |
739 | |
740 | def test_getNotNewByNames_excludes_by_archive(self): |
741 | names, distroarchseries, archives = self.createPublishingRecords() |
742 | diff --git a/lib/lp/soyuz/tests/test_packageset.py b/lib/lp/soyuz/tests/test_packageset.py |
743 | index abdce1f..8ac6777 100644 |
744 | --- a/lib/lp/soyuz/tests/test_packageset.py |
745 | +++ b/lib/lp/soyuz/tests/test_packageset.py |
746 | @@ -180,9 +180,9 @@ class TestPackagesetSet(TestCaseWithFactory): |
747 | def test_sets_including_source(self): |
748 | # Returns the list of sets including a source package |
749 | parent, child, package = self.buildSimpleHierarchy() |
750 | - self.assertEqual( |
751 | - sorted(self.ps_set.setsIncludingSource(package)), |
752 | - sorted((parent, child))) |
753 | + self.assertContentEqual( |
754 | + self.ps_set.setsIncludingSource(package), |
755 | + (parent, child)) |
756 | |
757 | # And can be limited to direct inclusion |
758 | result = self.ps_set.setsIncludingSource( |
759 | @@ -196,7 +196,7 @@ class TestPackagesetSet(TestCaseWithFactory): |
760 | parent, child, package = self.buildSimpleHierarchy(series) |
761 | result = self.ps_set.setsIncludingSource( |
762 | package, distroseries=series) |
763 | - self.assertEqual(sorted(result), sorted([parent, child])) |
764 | + self.assertContentEqual(result, [parent, child]) |
765 | |
766 | def test_sets_including_source_different_series(self): |
767 | # searches are limited to one series |
768 | @@ -209,9 +209,9 @@ class TestPackagesetSet(TestCaseWithFactory): |
769 | def test_sets_including_source_by_name(self): |
770 | # Returns the list osf sets including a source package |
771 | parent, child, package = self.buildSimpleHierarchy() |
772 | - self.assertEqual( |
773 | - sorted(self.ps_set.setsIncludingSource(package.name)), |
774 | - sorted([parent, child])) |
775 | + self.assertContentEqual( |
776 | + self.ps_set.setsIncludingSource(package.name), |
777 | + [parent, child]) |
778 | |
779 | def test_sets_including_source_unknown_name(self): |
780 | # A non-existent package name will throw an exception |
781 | @@ -415,29 +415,25 @@ class TestPackageset(TestCaseWithFactory): |
782 | def test_sources_included(self): |
783 | # Lists the source packages included in a set |
784 | packageset, packages = self.buildSet() |
785 | - self.assertEqual( |
786 | - sorted(packageset.sourcesIncluded()), sorted(packages)) |
787 | + self.assertContentEqual(packageset.sourcesIncluded(), packages) |
788 | |
789 | def test_get_sources_included(self): |
790 | # Lists the names of source packages included in a set |
791 | packageset, packages = self.buildSet() |
792 | - self.assertEqual( |
793 | - sorted(packageset.getSourcesIncluded()), |
794 | - sorted(p.name for p in packages)) |
795 | + self.assertContentEqual( |
796 | + packageset.getSourcesIncluded(), [p.name for p in packages]) |
797 | |
798 | def test_sources_included_indirect(self): |
799 | # sourcesIncluded traverses the set tree, by default |
800 | packageset1, packages1 = self.buildSet() |
801 | packageset2, packages2 = self.buildSet() |
802 | packageset1.add((packageset2,)) |
803 | - self.assertEqual( |
804 | - sorted(packageset1.sourcesIncluded()), |
805 | - sorted(packages1 + packages2)) |
806 | + self.assertContentEqual( |
807 | + packageset1.sourcesIncluded(), packages1 + packages2) |
808 | |
809 | # direct_inclusion disables traversal |
810 | - self.assertEqual( |
811 | - sorted(packageset1.sourcesIncluded(direct_inclusion=True)), |
812 | - sorted(packages1)) |
813 | + self.assertContentEqual( |
814 | + packageset1.sourcesIncluded(direct_inclusion=True), packages1) |
815 | |
816 | def test_sources_multiply_included(self): |
817 | # Source packages included in multiple packagesets in a tree are only |
818 | @@ -446,12 +442,11 @@ class TestPackageset(TestCaseWithFactory): |
819 | packageset2, packages2 = self.buildSet(5) |
820 | packageset1.add(packages2[:2]) |
821 | packageset1.add((packageset2,)) |
822 | - self.assertEqual( |
823 | - sorted(packageset1.sourcesIncluded(direct_inclusion=True)), |
824 | - sorted(packages1 + packages2[:2])) |
825 | - self.assertEqual( |
826 | - sorted(packageset1.sourcesIncluded()), |
827 | - sorted(packages1 + packages2)) |
828 | + self.assertContentEqual( |
829 | + packageset1.sourcesIncluded(direct_inclusion=True), |
830 | + packages1 + packages2[:2]) |
831 | + self.assertContentEqual( |
832 | + packageset1.sourcesIncluded(), packages1 + packages2) |
833 | |
834 | def test_is_source_included(self): |
835 | # Test if a source package name is included in a set |
836 | @@ -481,22 +476,20 @@ class TestPackageset(TestCaseWithFactory): |
837 | # Adding source packages to a package set repeatedly has no effect |
838 | packageset, packages = self.buildSet() |
839 | packageset.add(packages) |
840 | - self.assertEqual( |
841 | - sorted(packageset.sourcesIncluded()), sorted(packages)) |
842 | + self.assertContentEqual(packageset.sourcesIncluded(), packages) |
843 | |
844 | def test_remove_sources(self): |
845 | # Source packages can be removed from a set |
846 | packageset, packages = self.buildSet(5) |
847 | packageset.remove(packages[:2]) |
848 | - self.assertEqual( |
849 | - sorted(packageset.sourcesIncluded()), sorted(packages[2:])) |
850 | + self.assertContentEqual(packageset.sourcesIncluded(), packages[2:]) |
851 | |
852 | def test_remove_non_preset_sources(self): |
853 | # Trying to remove source packages that are *not* in the set, has no |
854 | # effect. |
855 | packageset, packages = self.buildSet() |
856 | packageset.remove([self.factory.makeSourcePackageName()]) |
857 | - self.assertTrue(sorted(packageset.sourcesIncluded()), sorted(packages)) |
858 | + self.assertContentEqual(packageset.sourcesIncluded(), packages) |
859 | |
860 | def test_sets_included(self): |
861 | # Returns the sets included in a set |
862 | @@ -505,8 +498,7 @@ class TestPackageset(TestCaseWithFactory): |
863 | parent.add((child,)) |
864 | grandchild = self.factory.makePackageset() |
865 | child.add((grandchild,)) |
866 | - self.assertEqual( |
867 | - sorted(parent.setsIncluded()), sorted([child, grandchild])) |
868 | + self.assertContentEqual(parent.setsIncluded(), [child, grandchild]) |
869 | self.assertEqual( |
870 | list(parent.setsIncluded(direct_inclusion=True)), [child]) |
871 | |
872 | @@ -520,8 +512,8 @@ class TestPackageset(TestCaseWithFactory): |
873 | grandchild = self.factory.makePackageset() |
874 | child.add((grandchild,)) |
875 | child2.add((grandchild,)) |
876 | - self.assertEqual( |
877 | - sorted(parent.setsIncluded()), sorted([child, child2, grandchild])) |
878 | + self.assertContentEqual( |
879 | + parent.setsIncluded(), [child, child2, grandchild]) |
880 | |
881 | def test_sets_included_by(self): |
882 | # Returns the set of sets including a set |
883 | @@ -530,8 +522,7 @@ class TestPackageset(TestCaseWithFactory): |
884 | parent.add((child,)) |
885 | grandchild = self.factory.makePackageset() |
886 | child.add((grandchild,)) |
887 | - self.assertEqual( |
888 | - sorted(grandchild.setsIncludedBy()), sorted([child, parent])) |
889 | + self.assertContentEqual(grandchild.setsIncludedBy(), [child, parent]) |
890 | self.assertEqual( |
891 | list(grandchild.setsIncludedBy(direct_inclusion=True)), [child]) |
892 | |
893 | @@ -541,8 +532,7 @@ class TestPackageset(TestCaseWithFactory): |
894 | child = self.factory.makePackageset() |
895 | child2 = self.factory.makePackageset() |
896 | parent.add((child, child2)) |
897 | - self.assertEqual( |
898 | - sorted(parent.setsIncluded()), sorted([child, child2])) |
899 | + self.assertContentEqual(parent.setsIncluded(), [child, child2]) |
900 | parent.remove((child,)) |
901 | self.assertEqual(list(parent.setsIncluded()), [child2]) |
902 | |
903 | @@ -553,11 +543,9 @@ class TestPackageset(TestCaseWithFactory): |
904 | grandchild = self.factory.makePackageset() |
905 | parent.add((child,)) |
906 | child.add((grandchild,)) |
907 | - self.assertEqual( |
908 | - sorted(parent.setsIncluded()), sorted([child, grandchild])) |
909 | + self.assertContentEqual(parent.setsIncluded(), [child, grandchild]) |
910 | parent.remove((grandchild,)) |
911 | - self.assertEqual( |
912 | - sorted(parent.setsIncluded()), sorted([child, grandchild])) |
913 | + self.assertContentEqual(parent.setsIncluded(), [child, grandchild]) |
914 | |
915 | def test_sources_shared_by(self): |
916 | # Lists the source packages shared between two packagesets |
917 | @@ -567,9 +555,8 @@ class TestPackageset(TestCaseWithFactory): |
918 | |
919 | pset1.add(pkgs2[:2]) |
920 | pset2.add(pkgs1[:2]) |
921 | - self.assertEqual( |
922 | - sorted(pset1.sourcesSharedBy(pset2)), |
923 | - sorted(pkgs1[:2] + pkgs2[:2])) |
924 | + self.assertContentEqual( |
925 | + pset1.sourcesSharedBy(pset2), pkgs1[:2] + pkgs2[:2]) |
926 | |
927 | def test_get_sources_shared_by(self): |
928 | # List the names of source packages shared between two packagesets |
929 | @@ -579,9 +566,9 @@ class TestPackageset(TestCaseWithFactory): |
930 | |
931 | pset1.add(pkgs2[:2]) |
932 | pset2.add(pkgs1[:2]) |
933 | - self.assertEqual( |
934 | - sorted(pset1.getSourcesSharedBy(pset2)), |
935 | - sorted(p.name for p in (pkgs1[:2] + pkgs2[:2]))) |
936 | + self.assertContentEqual( |
937 | + pset1.getSourcesSharedBy(pset2), |
938 | + [p.name for p in (pkgs1[:2] + pkgs2[:2])]) |
939 | |
940 | def test_sources_shared_by_subset(self): |
941 | # sourcesSharedBy takes subsets into account, unless told not to |
942 | @@ -590,7 +577,7 @@ class TestPackageset(TestCaseWithFactory): |
943 | self.assertTrue(pset1.sourcesSharedBy(pset2).is_empty()) |
944 | |
945 | pset1.add((pset2,)) |
946 | - self.assertEqual(sorted(pset1.sourcesSharedBy(pset2)), sorted(pkgs2)) |
947 | + self.assertContentEqual(pset1.sourcesSharedBy(pset2), pkgs2) |
948 | self.assertTrue( |
949 | pset1.sourcesSharedBy(pset2, direct_inclusion=True).is_empty()) |
950 | |
951 | @@ -603,50 +590,47 @@ class TestPackageset(TestCaseWithFactory): |
952 | |
953 | pset1.add(pkgs2[:2] + pkgs3) |
954 | pset2.add(pkgs1[:2] + [pset3]) |
955 | - self.assertEqual( |
956 | - sorted(pset1.sourcesSharedBy(pset2)), |
957 | - sorted(pkgs1[:2] + pkgs2[:2] + pkgs3)) |
958 | - self.assertEqual( |
959 | - sorted(pset1.sourcesSharedBy(pset2)), |
960 | - sorted(pset2.sourcesSharedBy(pset1))) |
961 | + self.assertContentEqual( |
962 | + pset1.sourcesSharedBy(pset2), |
963 | + pkgs1[:2] + pkgs2[:2] + pkgs3) |
964 | + self.assertContentEqual( |
965 | + pset1.sourcesSharedBy(pset2), |
966 | + pset2.sourcesSharedBy(pset1)) |
967 | |
968 | def test_sources_not_shared_by(self): |
969 | # Lists source packages in the first set, but not the second |
970 | pset1, pkgs1 = self.buildSet(5) |
971 | pset2, pkgs2 = self.buildSet(5) |
972 | - self.assertEqual( |
973 | - sorted(pset1.sourcesNotSharedBy(pset2)), sorted(pkgs1)) |
974 | + self.assertContentEqual(pset1.sourcesNotSharedBy(pset2), pkgs1) |
975 | pset1.add(pkgs2[:2]) |
976 | pset2.add(pkgs1[:2]) |
977 | - self.assertEqual( |
978 | - sorted(pset1.sourcesNotSharedBy(pset2)), sorted(pkgs1[2:])) |
979 | + self.assertContentEqual(pset1.sourcesNotSharedBy(pset2), pkgs1[2:]) |
980 | |
981 | def test_get_sources_not_shared_by(self): |
982 | # List the names of source packages in the first set, but not the |
983 | # second |
984 | pset1, pkgs1 = self.buildSet(5) |
985 | pset2, pkgs2 = self.buildSet(5) |
986 | - self.assertEqual( |
987 | - sorted(pset1.getSourcesNotSharedBy(pset2)), |
988 | - sorted(p.name for p in pkgs1)) |
989 | + self.assertContentEqual( |
990 | + pset1.getSourcesNotSharedBy(pset2), |
991 | + [p.name for p in pkgs1]) |
992 | |
993 | pset1.add(pkgs2[:2]) |
994 | pset2.add(pkgs1[:2]) |
995 | - self.assertEqual( |
996 | - sorted(pset1.getSourcesNotSharedBy(pset2)), |
997 | - sorted(p.name for p in pkgs1[2:])) |
998 | + self.assertContentEqual( |
999 | + pset1.getSourcesNotSharedBy(pset2), |
1000 | + [p.name for p in pkgs1[2:]]) |
1001 | |
1002 | def test_sources_not_shared_by_subset(self): |
1003 | # sourcesNotSharedBy takes subsets into account, unless told not to |
1004 | pset1, pkgs1 = self.buildSet() |
1005 | pset2, pkgs2 = self.buildSet() |
1006 | - self.assertTrue(sorted(pset1.sourcesNotSharedBy(pset2)), sorted(pkgs1)) |
1007 | + self.assertContentEqual(pset1.sourcesNotSharedBy(pset2), pkgs1) |
1008 | |
1009 | pset2.add((pset1,)) |
1010 | self.assertTrue(pset1.sourcesNotSharedBy(pset2).is_empty()) |
1011 | - self.assertTrue( |
1012 | - sorted(pset1.sourcesNotSharedBy(pset2, direct_inclusion=True)), |
1013 | - sorted(pkgs1)) |
1014 | + self.assertContentEqual( |
1015 | + pset1.sourcesNotSharedBy(pset2, direct_inclusion=True), pkgs1) |
1016 | |
1017 | def test_add_unknown_name(self): |
1018 | # Adding an unknown package name will raise an error |
1019 | @@ -907,10 +891,10 @@ class TestArchivePermissionSet(TestCaseWithFactory): |
1020 | explicit_child = self.ap_set.newPackagesetUploader( |
1021 | self.archive, self.person, child, True) |
1022 | |
1023 | - self.assertEqual( |
1024 | - sorted(self.ap_set.uploadersForPackageset( |
1025 | - self.archive, child, direct_permissions=False)), |
1026 | - sorted((implicit_parent, explicit_child))) |
1027 | + self.assertContentEqual( |
1028 | + self.ap_set.uploadersForPackageset( |
1029 | + self.archive, child, direct_permissions=False), |
1030 | + (implicit_parent, explicit_child)) |
1031 | |
1032 | def test_uploaders_for_packageset_subpackagesets_removed(self): |
1033 | # archive permissions cease to apply to removed child packagesets |
Looks good!