Merge ~cjwatson/launchpad:services-mail-print-function into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 7f515d4d271c2d97307c6a6f5241c5f97532cf4e
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:services-mail-print-function
Merge into: launchpad:master
Diff against target: 603 lines (+94/-74)
11 files modified
lib/lp/services/mail/doc/emailauthentication.txt (+8/-8)
lib/lp/services/mail/doc/mailbox.txt (+2/-2)
lib/lp/services/mail/doc/notification-recipient-set.txt (+30/-26)
lib/lp/services/mail/doc/sending-mail.txt (+11/-10)
lib/lp/services/mail/doc/signedmessage.txt (+18/-16)
lib/lp/services/mail/notification.py (+4/-2)
lib/lp/services/mail/tests/incomingmail.txt (+4/-4)
lib/lp/services/mail/tests/test_doc.py (+4/-2)
lib/lp/services/mail/tests/test_incoming.py (+5/-2)
lib/lp/services/mail/tests/test_mbox_mailer.py (+5/-1)
lib/lp/services/mail/tests/test_stub.py (+3/-1)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+387928@code.launchpad.net

Commit message

Port lp.services.mail to print_function

Description of the change

I've ported some doctests to unicode_literals as well in the process.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/mail/doc/emailauthentication.txt b/lib/lp/services/mail/doc/emailauthentication.txt
2index 2a0b37f..e875e8c 100644
3--- a/lib/lp/services/mail/doc/emailauthentication.txt
4+++ b/lib/lp/services/mail/doc/emailauthentication.txt
5@@ -123,7 +123,7 @@ message.
6 GPGVerificationError: (7, 8, u'Bad signature')
7
8 >>> getUtility(IGPGHandler).getVerifiedSignature(
9- ... msg.signedContent.replace('\n', '\r\n'), msg.signature)
10+ ... msg.signedContent.replace(b'\n', b'\r\n'), msg.signature)
11 <...PymeSignature...>
12
13 authenticateEmail() doesn't have any problems verifying the signature:
14@@ -135,7 +135,7 @@ authenticateEmail() doesn't have any problems verifying the signature:
15 ... msg.parsed_string = msg.as_string()
16 ... principal = authenticateEmail(msg, accept_any_timestamp)
17 ... authenticated_person = IPerson(principal)
18- ... print authenticated_person.preferredemail.email
19+ ... print(authenticated_person.preferredemail.email)
20 test@canonical.com
21 test@canonical.com
22
23@@ -147,19 +147,19 @@ starts failing, Python is probably fixed, so the manual boundary parsing
24 hack can be removed.
25
26 >>> msg = read_test_message('signed_folded_header.txt')
27- >>> print msg.parsed_string #doctest: -NORMALIZE_WHITESPACE
28+ >>> print(msg.parsed_string) #doctest: -NORMALIZE_WHITESPACE
29 Date:...
30 ...
31 Content-Type: multipart/mixed;
32 boundary="--------------------EuxKj2iCbKjpUGkD"
33 ...
34
35- >>> print msg.get_payload(i=0).as_string() #doctest: -NORMALIZE_WHITESPACE
36+ >>> print(msg.get_payload(i=0).as_string()) #doctest: -NORMALIZE_WHITESPACE
37 Content-Type: multipart/mixed; boundary="--------------------EuxKj2iCbKjpUGkD"
38 ...
39
40 >>> principal = authenticateEmail(msg, accept_any_timestamp)
41- >>> print IPerson(principal).displayname
42+ >>> print(IPerson(principal).displayname)
43 Sample Person
44
45
46@@ -184,7 +184,7 @@ An unsigned email:
47 >>> IWeaklyAuthenticatedPrincipal.providedBy(principal)
48 True
49
50- >>> print launchbag.user.displayname
51+ >>> print(launchbag.user.displayname)
52 Foo Bar
53 >>> launchbag.login
54 'foo.bar@canonical.com'
55@@ -197,7 +197,7 @@ authenticated user:
56 >>> IWeaklyAuthenticatedPrincipal.providedBy(principal)
57 True
58
59- >>> print launchbag.user.displayname
60+ >>> print(launchbag.user.displayname)
61 Sample Person
62 >>> launchbag.login
63 'testing@canonical.com'
64@@ -211,7 +211,7 @@ principal.
65 >>> IWeaklyAuthenticatedPrincipal.providedBy(principal)
66 False
67
68- >>> print launchbag.user.displayname
69+ >>> print(launchbag.user.displayname)
70 Sample Person
71 >>> launchbag.login
72 'test@canonical.com'
73diff --git a/lib/lp/services/mail/doc/mailbox.txt b/lib/lp/services/mail/doc/mailbox.txt
74index 7761772..4da62d6 100644
75--- a/lib/lp/services/mail/doc/mailbox.txt
76+++ b/lib/lp/services/mail/doc/mailbox.txt
77@@ -76,7 +76,7 @@ before:
78 >>> id, raw_mail = mails[0]
79 >>> import email
80 >>> mail = email.message_from_string(raw_mail)
81- >>> print mail['Message-ID']
82+ >>> print(mail['Message-ID'])
83 <test1>
84
85 When we're done using the mail box we have to close it:
86@@ -91,7 +91,7 @@ Since we didn't delete the mail, it's still in there:
87 2
88 >>> id, raw_mail = mails[0]
89 >>> mail = email.message_from_string(raw_mail)
90- >>> print mail['Message-ID']
91+ >>> print(mail['Message-ID'])
92 <test1>
93
94 Let's delete all mails in the mail box:
95diff --git a/lib/lp/services/mail/doc/notification-recipient-set.txt b/lib/lp/services/mail/doc/notification-recipient-set.txt
96index 94e97be..7dea670 100644
97--- a/lib/lp/services/mail/doc/notification-recipient-set.txt
98+++ b/lib/lp/services/mail/doc/notification-recipient-set.txt
99@@ -55,7 +55,7 @@ name.
100 It's also possible to iterate over the recipients:
101
102 >>> for person in recipients:
103- ... print person.displayname
104+ ... print(person.displayname)
105 Celso Providelo
106 Sample Person
107
108@@ -98,13 +98,17 @@ Obtaining the rationale
109 You can obtain the rationale, header tuple by using the getReason()
110 method:
111
112- >>> recipients.getReason(cprov)
113- ('You are notified for no reason.', 'Why not')
114+ >>> def print_reason(reason):
115+ ... rationale, header = reason
116+ ... print('%s (%s)' % (header, rationale))
117+
118+ >>> print_reason(recipients.getReason(cprov))
119+ Why not (You are notified for no reason.)
120
121 You can also ask the reason associated with an email address:
122
123- >>> recipients.getReason('test@canonical.com')
124- ('You are notified because...', 'Unknown')
125+ >>> print_reason(recipients.getReason('test@canonical.com'))
126+ Unknown (You are notified because...)
127
128 Requesting the reason for somebody that is not a recipient raises a
129 UnknownRecipientError:
130@@ -114,7 +118,7 @@ UnknownRecipientError:
131 ...
132 UnknownRecipientError: ...
133
134- >>> recipients.getReason('no-priv@canonical.com')
135+ >>> recipients.getReason(six.ensure_str('no-priv@canonical.com'))
136 Traceback (most recent call last):
137 ...
138 UnknownRecipientError: 'no-priv@canonical.com'
139@@ -135,7 +139,7 @@ person:
140
141 >>> ubuntu_team = person_set.getByName('ubuntu-team')
142 >>> ignored = login_person(ubuntu_team.teamowner)
143- >>> print ubuntu_team.preferredemail.email
144+ >>> print(ubuntu_team.preferredemail.email)
145 support@ubuntu.com
146
147 >>> recipients.add(ubuntu_team, 'You are notified for fun.', 'Fun')
148@@ -158,7 +162,7 @@ addresses are added to the recipients list, and this recursively.
149
150 >>> recipients = NotificationRecipientSet()
151 >>> ubuntu_gnome_team = person_set.getByName('name18')
152- >>> print ubuntu_gnome_team.preferredemail
153+ >>> print(ubuntu_gnome_team.preferredemail)
154 None
155
156 >>> recipients.add(
157@@ -182,7 +186,7 @@ be notified for they're a member of Warty Security Team, itself a member of
158 Ubuntu Gnome Team:
159
160 >>> warty_security_team = person_set.getByName('name20')
161- >>> print warty_security_team.displayname
162+ >>> print(warty_security_team.displayname)
163 Warty Security Team
164
165 >>> sample_person.inTeam(warty_security_team)
166@@ -202,11 +206,11 @@ Ubuntu Gnome Team:
167
168 Their email will have the same rationale than the team:
169
170- >>> recipients.getReason(ubuntu_gnome_team)
171- ('Notified because a member of the team', 'Team')
172+ >>> print_reason(recipients.getReason(ubuntu_gnome_team))
173+ Team (Notified because a member of the team)
174
175- >>> recipients.getReason('test@canonical.com')
176- ('Notified because a member of the team', 'Team')
177+ >>> print_reason(recipients.getReason('test@canonical.com'))
178+ Team (Notified because a member of the team)
179
180
181 Adding many persons at the same time
182@@ -221,11 +225,11 @@ be added with the same rationale:
183 >>> [person.displayname for person in recipients.getRecipients()]
184 [u'No Privileges Person', u'Sample Person']
185
186- >>> recipients.getReason(no_priv)
187- ('Notified for fun.', 'Fun')
188+ >>> print_reason(recipients.getReason(no_priv))
189+ Fun (Notified for fun.)
190
191- >>> recipients.getReason(sample_person)
192- ('Notified for fun.', 'Fun')
193+ >>> print_reason(recipients.getReason(sample_person))
194+ Fun (Notified for fun.)
195
196
197 Removing recipients
198@@ -262,8 +266,8 @@ will be the one returned.
199 >>> recipients.add(sample_person, 'A good reason', 'Good')
200 >>> recipients.add(sample_person, 'Not a good reason', 'No good')
201
202- >>> recipients.getReason(sample_person)
203- ('A good reason', 'Good')
204+ >>> print_reason(recipients.getReason(sample_person))
205+ Good (A good reason)
206
207 But if a person already had a rationale added through a team, the
208 rationale specific to the person is used:
209@@ -274,8 +278,8 @@ rationale specific to the person is used:
210 ... 'Team')
211 >>> recipients.add(sample_person, 'A more specific reason', 'Specific')
212
213- >>> recipients.getReason('test@canonical.com')
214- ('A more specific reason', 'Specific')
215+ >>> print_reason (recipients.getReason('test@canonical.com'))
216+ Specific (A more specific reason)
217
218 Adding a rationale for another team won't override the one for the first
219 one:
220@@ -285,8 +289,8 @@ one:
221 ... warty_security_team, 'Member of Warty', 'Warty')
222 >>> recipients.add(
223 ... ubuntu_gnome_team, 'Member of Ubuntu Gnome', 'Ubuntu Gnome')
224- >>> recipients.getReason('test@canonical.com')
225- ('Member of Warty', 'Warty')
226+ >>> print_reason(recipients.getReason('test@canonical.com'))
227+ Warty (Member of Warty)
228
229 Nor adding a team rationale, when there is already one for the person:
230
231@@ -294,8 +298,8 @@ Nor adding a team rationale, when there is already one for the person:
232 >>> recipients.add(sample_person, 'Sample Person', 'Person')
233 >>> recipients.add(
234 ... warty_security_team, 'Member of Warty.', 'Team')
235- >>> recipients.getReason('test@canonical.com')
236- ('Sample Person', 'Person')
237+ >>> print_reason(recipients.getReason('test@canonical.com'))
238+ Person (Sample Person)
239
240
241 Merging recipients set
242@@ -313,7 +317,7 @@ recipient is already part of the first set, the reason won't be updated.
243 >>> recipients.update(other_recipients)
244 >>> for person in recipients:
245 ... reason, code = recipients.getReason(person)
246- ... print '%s: %s (%s)' % (person.displayname, code, reason)
247+ ... print('%s: %s (%s)' % (person.displayname, code, reason))
248 Celso Providelo: B (Reason B)
249 No Privileges Person: B (Reason B)
250 Sample Person: A (Reason A)
251diff --git a/lib/lp/services/mail/doc/sending-mail.txt b/lib/lp/services/mail/doc/sending-mail.txt
252index 90da8d7..f4f0e7f 100644
253--- a/lib/lp/services/mail/doc/sending-mail.txt
254+++ b/lib/lp/services/mail/doc/sending-mail.txt
255@@ -182,7 +182,7 @@ surrounded by quotes and quoted if necessary:
256
257 >>> from_addr, to_addr, raw_message = stub.test_emails.pop()
258 >>> msg = email.message_from_string(raw_message)
259- >>> print msg['From']
260+ >>> print(msg['From'])
261 "Foo \[Baz\] \" Bar" <foo.bar@canonical.com>
262
263
264@@ -191,14 +191,14 @@ non-ASCII str object is passed, it will throw a UnicodeDecodeError.
265
266 >>> simple_sendmail(
267 ... from_addr=u'foo.bar@canonical.com',
268- ... to_addrs='test@canonical.com',
269+ ... to_addrs=b'test@canonical.com',
270 ... subject=u'Subject',
271 ... body=u'Content')
272 '...launchpad@...'
273
274 >>> simple_sendmail(
275- ... from_addr='F\xf4\xf4 Bar <foo.bar@canonical.com>',
276- ... to_addrs='test@canonical.com',
277+ ... from_addr=b'F\xf4\xf4 Bar <foo.bar@canonical.com>',
278+ ... to_addrs=b'test@canonical.com',
279 ... subject=u'Subject',
280 ... body=u'Content')
281 Traceback (most recent call last):
282@@ -207,15 +207,15 @@ non-ASCII str object is passed, it will throw a UnicodeDecodeError.
283 ordinal not in range(128)
284
285 >>> simple_sendmail(
286- ... from_addr='foo.bar@canonical.com',
287+ ... from_addr=b'foo.bar@canonical.com',
288 ... to_addrs=u'test@canonical.com',
289 ... subject=u'Subject',
290 ... body=u'Content')
291 '...launchpad@...'
292
293 >>> simple_sendmail(
294- ... from_addr='Foo Bar <foo.bar@canonical.com>',
295- ... to_addrs=['S\xc4\x85mple Person <test@canonical.com>'],
296+ ... from_addr=b'Foo Bar <foo.bar@canonical.com>',
297+ ... to_addrs=[b'S\xc4\x85mple Person <test@canonical.com>'],
298 ... subject=u'Subject',
299 ... body=u'Content')
300 Traceback (most recent call last):
301@@ -249,7 +249,7 @@ that the precedence header was not added.
302 'Forgot password'
303 >>> msg.get_payload(decode=True)
304 'Content'
305- >>> print msg['Precedence']
306+ >>> print(msg['Precedence'])
307 None
308
309
310@@ -313,8 +313,9 @@ are ignored.
311 >>> transaction.commit()
312
313 >>> from_addr, to_addrs, raw_message = stub.test_emails.pop()
314- >>> to_addrs
315- ['no-priv@canonical.com']
316+ >>> for to_addr in to_addrs:
317+ ... print(to_addr)
318+ no-priv@canonical.com
319
320 >>> sent_msg = email.message_from_string(raw_message)
321 >>> sent_msg['To']
322diff --git a/lib/lp/services/mail/doc/signedmessage.txt b/lib/lp/services/mail/doc/signedmessage.txt
323index cd03bf8..f80d1ef 100644
324--- a/lib/lp/services/mail/doc/signedmessage.txt
325+++ b/lib/lp/services/mail/doc/signedmessage.txt
326@@ -14,8 +14,10 @@ the attributes are correctly set.
327 True
328 >>> msg['To']
329 'someone'
330- >>> msg.parsed_string
331- 'To: someone\n\nHello.'
332+ >>> print(msg.parsed_string)
333+ To: someone
334+ <BLANKLINE>
335+ Hello.
336
337
338 We have some test messages that can be easily accessed by
339@@ -27,12 +29,12 @@ signature is inline with the signed content:
340
341 You can access the headers of the message:
342
343- >>> print msg['From']
344+ >>> print(msg['From'])
345 Sample Person <test@canonical.com>
346
347 The raw text that was signed is available as msg.signedContent:
348
349- >>> print msg.signedContent
350+ >>> print(msg.signedContent)
351 Some signed content.
352 <BLANKLINE>
353 With multiple paragraphs.
354@@ -41,14 +43,14 @@ And to make it easier to work with, it's available as an email.message
355 object as well:
356
357 >>> signed_msg = msg.signedMessage
358- >>> print signed_msg.get_payload()
359+ >>> print(signed_msg.get_payload())
360 Some signed content.
361 <BLANKLINE>
362 With multiple paragraphs.
363
364 Finally the signature can be accessed via msg.signature:
365
366- >>> print msg.signature
367+ >>> print(msg.signature)
368 -----BEGIN PGP SIGNATURE-----
369 Version: GnuPG v1.2.5 (GNU/Linux)
370 <BLANKLINE>
371@@ -63,14 +65,14 @@ after the content has been signed, so the signed content should be
372 unescaped.
373
374 >>> msg = read_test_message('signed_dash_escaped.txt')
375- >>> print msg.get_payload()
376+ >>> print(msg.get_payload())
377 -----BEGIN PGP SIGNED MESSAGE-----
378 ...
379 - --
380 Sample Person
381 ...
382
383- >>> print msg.signedContent
384+ >>> print(msg.signedContent)
385 Some signed content.
386 <BLANKLINE>
387 --
388@@ -84,7 +86,7 @@ contains of two MIME parts, the signed text, and the signature:
389
390 The signed content includes the MIME headers as well:
391
392- >>> print msg.signedContent
393+ >>> print(msg.signedContent)
394 Content-Type: text/plain; charset=us-ascii
395 Content-Disposition: inline
396 <BLANKLINE>
397@@ -93,15 +95,15 @@ The signed content includes the MIME headers as well:
398 In signedMessage you can access the headers and the content
399 separately:
400
401- >>> print msg.signedMessage['Content-Type']
402+ >>> print(msg.signedMessage['Content-Type'])
403 text/plain; charset=us-ascii
404- >>> print msg.signedMessage.get_payload()
405+ >>> print(msg.signedMessage.get_payload())
406 Some signed content.
407
408
409 And of course the signature is accessible as well:
410
411- >>> print msg.signature
412+ >>> print(msg.signature)
413 -----BEGIN PGP SIGNATURE-----
414 Version: GnuPG v1.2.5 (GNU/Linux)
415 <BLANKLINE>
416@@ -124,14 +126,14 @@ It handles signed multipart messages as well:
417
418 >>> msg = read_test_message('signed_multipart.txt')
419 >>> content, attachment = msg.signedMessage.get_payload()
420- >>> print content.get_payload()
421+ >>> print(content.get_payload())
422 Some signed content.
423 <BLANKLINE>
424- >>> print attachment.get_payload()
425+ >>> print(attachment.get_payload())
426 A signed attachment.
427 <BLANKLINE>
428
429- >>> print msg.signature
430+ >>> print(msg.signature)
431 -----BEGIN PGP SIGNATURE-----
432 Version: GnuPG v1.2.5 (GNU/Linux)
433 <BLANKLINE>
434@@ -141,7 +143,7 @@ It handles signed multipart messages as well:
435 -----END PGP SIGNATURE-----
436
437 >>> msg = read_test_message('signed_folded_header.txt')
438- >>> print msg.signedContent #doctest: -NORMALIZE_WHITESPACE
439+ >>> print(msg.signedContent) #doctest: -NORMALIZE_WHITESPACE
440 Content-Type: multipart/mixed;
441 boundary="--------------------EuxKj2iCbKjpUGkD"
442 ...
443diff --git a/lib/lp/services/mail/notification.py b/lib/lp/services/mail/notification.py
444index 7db0f55..adf0f95 100644
445--- a/lib/lp/services/mail/notification.py
446+++ b/lib/lp/services/mail/notification.py
447@@ -2,6 +2,8 @@
448 # GNU Affero General Public License version 3 (see the file LICENSE).
449 """Event handlers that send email notifications."""
450
451+from __future__ import absolute_import, print_function
452+
453 __metaclass__ = type
454 __all__ = [
455 'send_process_error_notification',
456@@ -83,10 +85,10 @@ def get_unified_diff(old_text, new_text, text_width):
457 Before the diff is produced, the texts are wrapped to the given text
458 width.
459
460- >>> print get_unified_diff(
461+ >>> print(get_unified_diff(
462 ... 'Some text\nAnother line\n',get_un
463 ... 'Some more text\nAnother line\n',
464- ... text_width=72)
465+ ... text_width=72))
466 - Some text
467 + Some more text
468 Another line
469diff --git a/lib/lp/services/mail/tests/incomingmail.txt b/lib/lp/services/mail/tests/incomingmail.txt
470index 996e23d..3982bb1 100644
471--- a/lib/lp/services/mail/tests/incomingmail.txt
472+++ b/lib/lp/services/mail/tests/incomingmail.txt
473@@ -122,7 +122,7 @@ wasn't a handler registered for that domain, an OOPS was recorded with
474 a link to the original message.
475
476 >>> from lp.testing.mail_helpers import pop_notifications
477- >>> print str(pop_notifications()[-1])
478+ >>> print(str(pop_notifications()[-1]))
479 From ...
480 Content-Type: multipart/mixed...
481 ...
482@@ -184,7 +184,7 @@ silently rejected.
483 >>> person_set = getUtility(IPersonSet)
484 >>> bigjools = person_set.getByEmail('launchpad@julian-edwards.com',
485 ... filter_status=False)
486- >>> print bigjools.account_status.name
487+ >>> print(bigjools.account_status.name)
488 NOACCOUNT
489
490 >>> msg = read_test_message('unsigned_inactive.txt')
491@@ -259,7 +259,7 @@ And submit an email to the handler.
492 An exception is raised, an OOPS is recorded, and an email is sent back
493 to the user, citing the OOPS ID, with the original message attached.
494
495- >>> print str(pop_notifications()[-1])
496+ >>> print(str(pop_notifications()[-1]))
497 From ...
498 Content-Type: multipart/mixed...
499 ...
500@@ -303,7 +303,7 @@ reporting in the web interface, are not ignored in the email interface.
501 ...
502 Unauthorized
503
504- >>> print str(pop_notifications()[-1])
505+ >>> print(str(pop_notifications()[-1]))
506 From ...
507 Content-Type: multipart/mixed...
508 ...
509diff --git a/lib/lp/services/mail/tests/test_doc.py b/lib/lp/services/mail/tests/test_doc.py
510index ed0f572..7a3f8ba 100644
511--- a/lib/lp/services/mail/tests/test_doc.py
512+++ b/lib/lp/services/mail/tests/test_doc.py
513@@ -49,12 +49,14 @@ class ProcessMailLayer(LaunchpadZopelessLayer):
514 special = {
515 'emailauthentication.txt': LayeredDocFileSuite(
516 '../doc/emailauthentication.txt',
517- setUp=setUp, tearDown=tearDown,
518+ setUp=lambda test: setUp(test, future=True), tearDown=tearDown,
519 layer=ProcessMailLayer,
520 stdout_logging=False)
521 }
522
523
524 def test_suite():
525- suite = build_test_suite(here, special, layer=DatabaseFunctionalLayer)
526+ suite = build_test_suite(
527+ here, special, setUp=lambda test: setUp(test, future=True),
528+ layer=DatabaseFunctionalLayer)
529 return suite
530diff --git a/lib/lp/services/mail/tests/test_incoming.py b/lib/lp/services/mail/tests/test_incoming.py
531index 28bac00..3d2e625 100644
532--- a/lib/lp/services/mail/tests/test_incoming.py
533+++ b/lib/lp/services/mail/tests/test_incoming.py
534@@ -1,7 +1,6 @@
535 # Copyright 2009-2016 Canonical Ltd. This software is licensed under the
536 # GNU Affero General Public License version 3 (see the file LICENSE).
537
538-
539 from doctest import DocTestSuite
540 from email.mime.multipart import MIMEMultipart
541 import logging
542@@ -43,7 +42,10 @@ from lp.testing.fixture import ZopeUtilityFixture
543 from lp.testing.gpgkeys import import_secret_test_key
544 from lp.testing.layers import LaunchpadZopelessLayer
545 from lp.testing.mail_helpers import pop_notifications
546-from lp.testing.systemdocs import LayeredDocFileSuite
547+from lp.testing.systemdocs import (
548+ LayeredDocFileSuite,
549+ setGlobs,
550+ )
551
552
553 @implementer(IMailHandler)
554@@ -344,6 +346,7 @@ class TestExtractAddresses(TestCaseWithFactory):
555
556
557 def setUp(test):
558+ setGlobs(test, future=True)
559 test._old_policy = setSecurityPolicy(LaunchpadSecurityPolicy)
560 switch_dbuser(config.processmail.dbuser)
561
562diff --git a/lib/lp/services/mail/tests/test_mbox_mailer.py b/lib/lp/services/mail/tests/test_mbox_mailer.py
563index 078bb32..f46248e 100644
564--- a/lib/lp/services/mail/tests/test_mbox_mailer.py
565+++ b/lib/lp/services/mail/tests/test_mbox_mailer.py
566@@ -9,11 +9,15 @@ import tempfile
567
568 from zope.testing.cleanup import cleanUp
569
570-from lp.testing.systemdocs import LayeredDocFileSuite
571+from lp.testing.systemdocs import (
572+ LayeredDocFileSuite,
573+ setGlobs,
574+ )
575
576
577 def setup(testobj):
578 """Set up for doc test"""
579+ setGlobs(testobj, future=True)
580 fd, mbox_filename = tempfile.mkstemp()
581 os.close(fd)
582 testobj.globs['mbox_filename'] = mbox_filename
583diff --git a/lib/lp/services/mail/tests/test_stub.py b/lib/lp/services/mail/tests/test_stub.py
584index 8945153..3ea22fb 100644
585--- a/lib/lp/services/mail/tests/test_stub.py
586+++ b/lib/lp/services/mail/tests/test_stub.py
587@@ -1,6 +1,8 @@
588 # Copyright 2009-2019 Canonical Ltd. This software is licensed under the
589 # GNU Affero General Public License version 3 (see the file LICENSE).
590
591+from __future__ import absolute_import, print_function
592+
593 __metaclass__ = type
594
595 from doctest import DocTestSuite
596@@ -64,7 +66,7 @@ def test_simple_sendmail():
597
598 >>> sorted_test_emails = sorted(list(stub.test_emails))
599 >>> for from_addr, to_addrs, raw_message in sorted_test_emails:
600- ... print from_addr, to_addrs, 'nobody@example.com' in raw_message
601+ ... print(from_addr, to_addrs, 'nobody@example.com' in raw_message)
602 bounces@canonical.com ['nobody2@example.com'] True
603 bounces@canonical.com ['nobody2@example.com'] False
604

Subscribers

People subscribed via source and target branches

to status/vote changes: