当前位置: 首页>>代码示例>>Python>>正文


Python mailbox.mboxMessage方法代码示例

本文整理汇总了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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_mailbox.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_mailbox.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_mailbox.py

示例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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_mailbox.py

示例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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_mailbox.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_mailbox.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_mailbox.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_mailbox.py

示例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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_mailbox.py

示例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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_mailbox.py

示例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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_mailbox.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_mailbox.py

示例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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_mailbox.py


注:本文中的mailbox.mboxMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。