Skip to content

Commit f3d0155

Browse files
committed
Fix test for mailer.standard_message
Python3 needs normal (unicode) strings while python2 needs UTF-8 encoded strings for the mail interface.
1 parent ef3f007 commit f3d0155

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/test_mailgw.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4445,12 +4445,17 @@ def testForwardedMessageAttachment(self):
44454445
def testStandardMsg(self):
44464446
self.instance.config['MAIL_DOMAIN'] = 'example.com'
44474447
name = u'Accented chars \xe4\xf6\xfc\xc4\xd6\xdc\xdf'
4448-
name = name.encode('utf-8')
4448+
# Python2 wants an UTF-8 string in first component of adr and content
4449+
# while Python3 wants a String
4450+
# It *may* be a bug that the subject can be Unicode in python2.
4451+
# But it doesn't hurt if the encoding happens to be utf-8
4452+
if sys.version_info[0] <= 2:
4453+
name = name.encode('utf-8')
44494454
44504455
to = [adr]
44514456
adr = (name, adr)
44524457
mailer = roundupdb.Mailer(self.db.config)
4453-
mailer.standard_message(to, name, name, author=adr)
4458+
mailer.standard_message(to, subject=name, content=name, author=adr)
44544459
assert os.path.exists(SENDMAILDEBUG)
44554460
self.compareMessages(self._get_mail(),
44564461
'''

0 commit comments

Comments
 (0)