Merge ~cjwatson/launchpad:py3-assertContentEqual into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 7fbe38c50bb8a6bf1a1e49f2a17e6b91bbb5315a
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-assertContentEqual
Merge into: launchpad:master
Diff against target: 39 lines (+4/-6)
2 files modified
lib/lp/registry/browser/tests/test_person_webservice.py (+3/-4)
lib/lp/soyuz/mail/tests/test_packageupload.py (+1/-2)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+398629@code.launchpad.net

Commit message

Use assertContentEqual for some unorderable types

Description of the change

Neither `Person` nor `EmailAddress` is orderable, and in any case the assertion in `TestPersonEmailSecurity.test_logged_in_can_access` was vacuous because it was asserting that a list wasn't equal to an integer.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/registry/browser/tests/test_person_webservice.py b/lib/lp/registry/browser/tests/test_person_webservice.py
2index 07685fb..a4b8150 100644
3--- a/lib/lp/registry/browser/tests/test_person_webservice.py
4+++ b/lib/lp/registry/browser/tests/test_person_webservice.py
5@@ -64,10 +64,9 @@ class TestPersonEmailSecurity(TestCaseWithFactory):
6 accessor = self.factory.makePerson()
7 lp = launchpadlib_for("test", accessor.name)
8 person = lp.people['target']
9- emails = sorted(list(person.confirmed_email_addresses))
10- self.assertNotEqual(
11- sorted([self.email_one, self.email_two]),
12- len(emails))
13+ emails = [entry.email for entry in person.confirmed_email_addresses]
14+ self.assertContentEqual(
15+ ['test1@example.com', 'test2@example.com'], emails)
16
17 def test_anonymous_cannot_access(self):
18 # An anonymous launchpadlib connection cannot see email addresses.
19diff --git a/lib/lp/soyuz/mail/tests/test_packageupload.py b/lib/lp/soyuz/mail/tests/test_packageupload.py
20index d39d9c3..3e9c0b1 100644
21--- a/lib/lp/soyuz/mail/tests/test_packageupload.py
22+++ b/lib/lp/soyuz/mail/tests/test_packageupload.py
23@@ -12,7 +12,6 @@ from testtools.matchers import (
24 Contains,
25 ContainsDict,
26 Equals,
27- KeysEqual,
28 )
29 from zope.component import getUtility
30 from zope.security.proxy import removeSecurityProxy
31@@ -404,7 +403,7 @@ class TestNotification(TestCaseWithFactory):
32 observed, _ = PackageUploadMailer.getRecipientsForAction(
33 'accepted', info, blamer, None, [], archive, distroseries,
34 PackagePublishingPocket.RELEASE)
35- self.assertThat(observed, KeysEqual(*expected))
36+ self.assertContentEqual(expected, observed.keys())
37
38 def test_getRecipientsForAction_good_emails(self):
39 # Test getRecipientsForAction with good email addresses..

Subscribers

People subscribed via source and target branches

to status/vote changes: