本文整理汇总了Python中mailbox.mboxMessage方法的典型用法代码示例。如果您正苦于以下问题:Python mailbox.mboxMessage方法的具体用法?Python mailbox.mboxMessage怎么用?Python mailbox.mboxMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailbox
的用法示例。
在下文中一共展示了mailbox.mboxMessage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_babyl_to_mboxmmdf
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_babyl_to_mboxmmdf(self):
# Convert BabylMessage to mboxMessage and MMDFMessage
pairs = (('unseen', 'O'), ('deleted', 'ROD'), ('filed', 'RO'),
('answered', 'ROA'), ('forwarded', 'RO'), ('edited', 'RO'),
('resent', 'RO'))
for setting, result in pairs:
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg = mailbox.BabylMessage(_sample_message)
msg.add_label(setting)
self.assertEqual(class_(msg).get_flags(), result)
msg = mailbox.BabylMessage(_sample_message)
for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded',
'edited', 'resent'):
msg.add_label(label)
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
self.assertEqual(class_(msg).get_flags(), 'ODA')
示例2: test_add_mbox_or_mmdf_message
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_add_mbox_or_mmdf_message(self):
# Add an mboxMessage or MMDFMessage
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg = class_('From foo@bar blah\nFrom: foo\n\n0\n')
key = self._box.add(msg)
示例3: test_explain_to
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_explain_to(self):
# Copy self's format-specific data to other message formats.
# This test is superficial; better ones are in TestMessageConversion.
msg = self._factory()
for class_ in (mailbox.Message, mailbox.MaildirMessage,
mailbox.mboxMessage, mailbox.MHMessage,
mailbox.BabylMessage, mailbox.MMDFMessage):
other_msg = class_()
msg._explain_to(other_msg)
other_msg = email.message.Message()
self.assertRaises(TypeError, lambda: msg._explain_to(other_msg))
示例4: test_initialize_with_unixfrom
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_initialize_with_unixfrom(self):
# Initialize with a message that already has a _unixfrom attribute
msg = mailbox.Message(_sample_message)
msg.set_unixfrom('From foo@bar blah')
msg = mailbox.mboxMessage(msg)
self.assertEqual(msg.get_from(), 'foo@bar blah')
示例5: test_from
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_from(self):
# Get and set "From " line
msg = mailbox.mboxMessage(_sample_message)
self._check_from(msg)
msg.set_from('foo bar')
self.assertEqual(msg.get_from(), 'foo bar')
msg.set_from('foo@bar', True)
self._check_from(msg, 'foo@bar')
msg.set_from('blah@temp', time.localtime())
self._check_from(msg, 'blah@temp')
示例6: test_flags
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_flags(self):
# Use get_flags(), set_flags(), add_flag(), remove_flag()
msg = mailbox.mboxMessage(_sample_message)
self.assertEqual(msg.get_flags(), '')
msg.set_flags('F')
self.assertEqual(msg.get_flags(), 'F')
msg.set_flags('XODR')
self.assertEqual(msg.get_flags(), 'RODX')
msg.add_flag('FA')
self.assertEqual(msg.get_flags(), 'RODFAX')
msg.remove_flag('FDXA')
self.assertEqual(msg.get_flags(), 'RO')
self._check_sample(msg)
示例7: test_x_to_plain
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_x_to_plain(self):
# Convert all formats to Message
for class_ in (mailbox.Message, mailbox.MaildirMessage,
mailbox.mboxMessage, mailbox.MHMessage,
mailbox.BabylMessage, mailbox.MMDFMessage):
msg = class_(_sample_message)
msg_plain = mailbox.Message(msg)
self._check_sample(msg_plain)
示例8: test_x_to_invalid
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_x_to_invalid(self):
# Convert all formats to an invalid format
for class_ in (mailbox.Message, mailbox.MaildirMessage,
mailbox.mboxMessage, mailbox.MHMessage,
mailbox.BabylMessage, mailbox.MMDFMessage):
self.assertRaises(TypeError, lambda: class_(False))
示例9: test_maildir_to_mboxmmdf
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_maildir_to_mboxmmdf(self):
# Convert MaildirMessage to mboxmessage and MMDFMessage
pairs = (('D', ''), ('F', 'F'), ('P', ''), ('R', 'A'), ('S', 'R'),
('T', 'D'), ('DFPRST', 'RDFA'))
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg_maildir = mailbox.MaildirMessage(_sample_message)
msg_maildir.set_date(0.0)
for setting, result in pairs:
msg_maildir.set_flags(setting)
msg = class_(msg_maildir)
self.assertEqual(msg.get_flags(), result)
self.assertEqual(msg.get_from(), 'MAILER-DAEMON %s' %
time.asctime(time.gmtime(0.0)))
msg_maildir.set_subdir('cur')
self.assertEqual(class_(msg_maildir).get_flags(), 'RODFA')
示例10: test_mboxmmdf_to_maildir
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_mboxmmdf_to_maildir(self):
# Convert mboxMessage and MMDFMessage to MaildirMessage
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg_mboxMMDF = class_(_sample_message)
msg_mboxMMDF.set_from('foo@bar', time.gmtime(0.0))
pairs = (('R', 'S'), ('O', ''), ('D', 'T'), ('F', 'F'), ('A', 'R'),
('RODFA', 'FRST'))
for setting, result in pairs:
msg_mboxMMDF.set_flags(setting)
msg = mailbox.MaildirMessage(msg_mboxMMDF)
self.assertEqual(msg.get_flags(), result)
self.assertEqual(msg.get_date(), 0.0)
msg_mboxMMDF.set_flags('O')
self.assertEqual(mailbox.MaildirMessage(msg_mboxMMDF).get_subdir(),
'cur')
示例11: test_mboxmmdf_to_mboxmmdf
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_mboxmmdf_to_mboxmmdf(self):
# Convert mboxMessage and MMDFMessage to mboxMessage and MMDFMessage
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg_mboxMMDF = class_(_sample_message)
msg_mboxMMDF.set_flags('RODFA')
msg_mboxMMDF.set_from('foo@bar')
for class2_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg2 = class2_(msg_mboxMMDF)
self.assertEqual(msg2.get_flags(), 'RODFA')
self.assertEqual(msg2.get_from(), 'foo@bar')
示例12: test_mboxmmdf_to_babyl
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_mboxmmdf_to_babyl(self):
# Convert mboxMessage and MMDFMessage to BabylMessage
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
msg = class_(_sample_message)
pairs = (('R', []), ('O', ['unseen']),
('D', ['unseen', 'deleted']), ('F', ['unseen']),
('A', ['unseen', 'answered']),
('RODFA', ['deleted', 'answered']))
for setting, result in pairs:
msg.set_flags(setting)
self.assertEqual(mailbox.BabylMessage(msg).get_labels(), result)
示例13: test_mh_to_mboxmmdf
# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import mboxMessage [as 别名]
def test_mh_to_mboxmmdf(self):
# Convert MHMessage to mboxMessage and MMDFMessage
pairs = (('unseen', 'O'), ('replied', 'ROA'), ('flagged', 'ROF'))
for setting, result in pairs:
msg = mailbox.MHMessage(_sample_message)
msg.add_sequence(setting)
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
self.assertEqual(class_(msg).get_flags(), result)
msg = mailbox.MHMessage(_sample_message)
msg.add_sequence('unseen')
msg.add_sequence('replied')
msg.add_sequence('flagged')
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
self.assertEqual(class_(msg).get_flags(), 'OFA')