Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 5848:f767a83a6af0
Fix test for mailer.standard_message
Python3 needs normal (unicode) strings while python2 needs UTF-8 encoded
strings for the mail interface.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Mon, 22 Jul 2019 19:59:28 +0200 |
| parents | 75586a0c26c0 |
| children | ad0ece9cb01b |
comparison
equal
deleted
inserted
replaced
| 5847:26cd8e8bbed3 | 5848:f767a83a6af0 |
|---|---|
| 4443 | 4443 |
| 4444 @pytest.mark.xfail | 4444 @pytest.mark.xfail |
| 4445 def testStandardMsg(self): | 4445 def testStandardMsg(self): |
| 4446 self.instance.config['MAIL_DOMAIN'] = 'example.com' | 4446 self.instance.config['MAIL_DOMAIN'] = 'example.com' |
| 4447 name = u'Accented chars \xe4\xf6\xfc\xc4\xd6\xdc\xdf' | 4447 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') | |
| 4449 adr = 'someone@example.com' | 4454 adr = 'someone@example.com' |
| 4450 to = [adr] | 4455 to = [adr] |
| 4451 adr = (name, adr) | 4456 adr = (name, adr) |
| 4452 mailer = roundupdb.Mailer(self.db.config) | 4457 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) |
| 4454 assert os.path.exists(SENDMAILDEBUG) | 4459 assert os.path.exists(SENDMAILDEBUG) |
| 4455 self.compareMessages(self._get_mail(), | 4460 self.compareMessages(self._get_mail(), |
| 4456 ''' | 4461 ''' |
| 4457 FROM: roundup-admin@example.com | 4462 FROM: roundup-admin@example.com |
| 4458 TO: someone@example.com | 4463 TO: someone@example.com |
