Colin Watson has proposed merging ~cjwatson/launchpad:py3-test-simple-sendmail
into launchpad:master.
Commit message:
Fix email sorting in test_simple_sendmail
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398782
Sorting by the message bodies isn't reliable enough, so sort the test messages
by their From: field instead.
--
Your team Launchpad code reviewers is requested to review the proposed merge of
~cjwatson/launchpad:py3-test-simple-sendmail into launchpad:master.
diff --git a/lib/lp/services/mail/tests/test_stub.py b/lib/lp/services/mail/tests/test_stub.py
index fedb7d2..f3b1c01 100644
--- a/lib/lp/services/mail/tests/test_stub.py
+++ b/lib/lp/services/mail/tests/test_stub.py
@@ -60,17 +60,19 @@ def test_simple_sendmail():
We have two emails, but we have no idea what order they are in!
- Let's sort them, and verify that the first one is the one we want
- because only the first one contains the string '[email protected]'
- in its raw message.
+ Let's sort them by their From: fields, and verify that the second one is
+ the one we want because only the second one contains the string
+ '[email protected]' in its raw message.
- >>> sorted_test_emails = sorted(list(stub.test_emails))
+ >>> sorted_test_emails = sorted(
+ ... list(stub.test_emails),
+ ... key=lambda email: message_from_bytes(email[2])['From'])
>>> for from_addr, to_addrs, raw_message in sorted_test_emails:
... print(from_addr, to_addrs, b'[email protected]' in raw_message)
- [email protected] ['[email protected]'] True
[email protected] ['[email protected]'] False
+ [email protected] ['[email protected]'] True
- >>> from_addr, to_addrs, raw_message = sorted_test_emails[0]
+ >>> from_addr, to_addrs, raw_message = sorted_test_emails[1]
>>> from_addr
'[email protected]'
>>> to_addrs
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help : https://help.launchpad.net/ListHelp