本文整理汇总了Python中mailman.email.message.Message.as_string方法的典型用法代码示例。如果您正苦于以下问题:Python Message.as_string方法的具体用法?Python Message.as_string怎么用?Python Message.as_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailman.email.message.Message
的用法示例。
在下文中一共展示了Message.as_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_non_ascii_message
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import as_string [as 别名]
def test_non_ascii_message(self):
msg = Message()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Content-Type'] = 'multipart/mixed'
msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
'plain', 'utf-8'))
mbox = digest_mbox(self._mlist)
mbox_path = os.path.join(self._mlist.data_path, 'digest.mmdf')
mbox.add(msg.as_string())
self._digestq.enqueue(
msg,
listname=self._mlist.fqdn_listname,
digest_path=mbox_path,
volume=1, digest_number=1)
# Use any error logs as the error message if the test fails.
error_log = LogFileMark('mailman.error')
self._runner.run()
# The runner will send the file to the shunt queue on exception.
self.assertEqual(len(self._shuntq.files), 0, error_log.read())
# There are two messages in the virgin queue: the digest as plain-text
# and as multipart.
messages = get_queue_messages('virgin')
self.assertEqual(len(messages), 2)
self.assertEqual(
sorted(item.msg.get_content_type() for item in messages),
['multipart/mixed', 'text/plain'])
for item in messages:
self.assertEqual(item.msg['subject'],
'Test Digest, Vol 1, Issue 1')
示例2: test_non_ascii_message
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import as_string [as 别名]
def test_non_ascii_message(self):
msg = Message()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Content-Type'] = 'multipart/mixed'
msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
'plain', 'utf-8'))
mbox = digest_mbox(self._mlist)
mbox.add(msg.as_string())
# Use any error logs as the error message if the test fails.
error_log = LogFileMark('mailman.error')
make_digest_messages(self._mlist, msg)
# The runner will send the file to the shunt queue on exception.
self.assertEqual(len(self._shuntq.files), 0, error_log.read())
self._check_virgin_queue()
示例3: test_non_ascii_message
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import as_string [as 别名]
def test_non_ascii_message(self):
# Subscribe some users receiving digests.
anne = subscribe(self._mlist, 'Anne')
anne.preferences.delivery_mode = DeliveryMode.mime_digests
bart = subscribe(self._mlist, 'Bart')
bart.preferences.delivery_mode = DeliveryMode.plaintext_digests
msg = Message()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Content-Type'] = 'multipart/mixed'
msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
'plain', 'utf-8'))
mbox = digest_mbox(self._mlist)
mbox.add(msg.as_string())
# Use any error logs as the error message if the test fails.
error_log = LogFileMark('mailman.error')
make_digest_messages(self._mlist, msg)
# The runner will send the file to the shunt queue on exception.
self.assertEqual(len(self._shuntq.files), 0, error_log.read())
self._check_virgin_queue()