Merge ~cjwatson/launchpad:py3-email-decode-bytes-2 into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ec95ca3b2ee9ee454b8809ce12a4e7b732238878
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-email-decode-bytes-2
Merge into: launchpad:master
Diff against target: 84 lines (+9/-9)
1 file modified
lib/lp/bugs/tests/bugs-emailinterface.txt (+9/-9)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398379@code.launchpad.net

Commit message

Fix types in email payload tests (take 2)

Description of the change

Similar to b893599efb655cc455da9909948fd2937513ac27 (https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/397707), but I missed a few spots.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/tests/bugs-emailinterface.txt b/lib/lp/bugs/tests/bugs-emailinterface.txt
2index 3a3c01a..271e77d 100644
3--- a/lib/lp/bugs/tests/bugs-emailinterface.txt
4+++ b/lib/lp/bugs/tests/bugs-emailinterface.txt
5@@ -361,7 +361,7 @@ And the person sending the email has received an error message.
6 ... print("Subject: %s" % sent_msg['Subject'])
7 ... print("To: %s" % ', '.join(to_addrs))
8 ... print()
9- ... print(error_mail.get_payload(decode=True))
10+ ... print(error_mail.get_payload(decode=True).decode('UTF-8'))
11
12 >>> print_latest_email()
13 Subject: Submit Request Failure
14@@ -2070,7 +2070,7 @@ The sent message contains two parts:
15
16 The first part is the error message, explaining what went wrong.
17
18- >>> print(failure_msg.get_payload(decode=True))
19+ >>> print(failure_msg.get_payload(decode=True).decode('UTF-8'))
20 An error occurred while processing a mail you sent to Launchpad's email
21 interface.
22 <BLANKLINE>
23@@ -2099,7 +2099,7 @@ error to happen.
24 'Original Message Subject'
25 >>> msg['Message-Id']
26 '<original@msg>'
27- >>> print(msg.get_payload(decode=True))
28+ >>> print(msg.get_payload(decode=True).decode('UTF-8'))
29 Original message body.
30
31 Sometimes the original error was caused by the original message being
32@@ -2213,7 +2213,7 @@ failure in an email.
33 >>> from_addr, to_addrs, raw_message = stub.test_emails[-1]
34 >>> sent_msg = email.message_from_string(raw_message)
35 >>> failure_msg, original_msg = sent_msg.get_payload()
36- >>> print(failure_msg.get_payload(decode=True))
37+ >>> print(failure_msg.get_payload(decode=True).decode('UTF-8'))
38 An error occurred while processing a mail you sent to Launchpad's email
39 interface.
40 <BLANKLINE>
41@@ -2261,7 +2261,7 @@ And the sender receives an email to let them know about the failing
42 >>> from_addr, to_addrs, raw_message = stub.test_emails[-1]
43 >>> sent_msg = email.message_from_string(raw_message)
44 >>> failure_msg, original_msg = sent_msg.get_payload()
45- >>> print(failure_msg.get_payload(decode=True))
46+ >>> print(failure_msg.get_payload(decode=True).decode('UTF-8'))
47 An error occurred while processing a mail you sent to Launchpad's email
48 interface.
49 <BLANKLINE>
50@@ -2335,7 +2335,7 @@ email too. Just send an email to `help@bugs.launchpad.net`.
51 ... """
52 >>> process_email(submit_mail)
53 >>> from_addr, to_addrs, raw_message = stub.test_emails[-1]
54- >>> print(raw_message)
55+ >>> print(raw_message.decode('UTF-8'))
56 Content-Type: text/plain; charset="utf-8"
57 ...
58 To: test@canonical.com
59@@ -2355,7 +2355,7 @@ Only mail coming from verified Launchpad users is answered.
60 ... help
61 ... """
62 >>> process_email(submit_mail)
63- >>> 'nobody@nowhere.com' in stub.test_emails[-1][2]
64+ >>> b'nobody@nowhere.com' in stub.test_emails[-1][2]
65 False
66
67 The help text is taken from the Launchpad help wiki as raw text, and
68@@ -3014,7 +3014,7 @@ importing machinery.
69 >>> comment_date = datetime(
70 ... 2008, 5, 19, 16, 19, 12, tzinfo=pytz.timezone('Europe/Prague'))
71
72- >>> initial_mail = b"""From: test@canonical.com
73+ >>> initial_mail = ("""From: test@canonical.com
74 ... To: %(bug_id)s@malone-domain
75 ... Date: %(date)s
76 ... Message-Id: <76543@launchpad.net>
77@@ -3026,7 +3026,7 @@ importing machinery.
78 ... """ % {
79 ... 'bug_id': bug_with_watch.id,
80 ... 'date': comment_date.strftime('%a %b %d %H:%M:%S %Z %Y'),
81- ... }
82+ ... }).encode('ASCII')
83 >>> message = getUtility(IMessageSet).fromEmail(
84 ... initial_mail, no_priv)
85

Subscribers

People subscribed via source and target branches

to status/vote changes: