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


Python mailbox.MaildirMessage方法代码示例

本文整理汇总了Python中mailbox.MaildirMessage方法的典型用法代码示例。如果您正苦于以下问题:Python mailbox.MaildirMessage方法的具体用法?Python mailbox.MaildirMessage怎么用?Python mailbox.MaildirMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mailbox的用法示例。


在下文中一共展示了mailbox.MaildirMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_MM

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_set_MM(self):
        # Set with a MaildirMessage instance
        msg0 = mailbox.MaildirMessage(self._template % 0)
        msg0.set_flags('TP')
        key = self._box.add(msg0)
        msg_returned = self._box.get_message(key)
        self.assertEqual(msg_returned.get_subdir(), 'new')
        self.assertEqual(msg_returned.get_flags(), 'PT')
        msg1 = mailbox.MaildirMessage(self._template % 1)
        self._box[key] = msg1
        msg_returned = self._box.get_message(key)
        self.assertEqual(msg_returned.get_subdir(), 'new')
        self.assertEqual(msg_returned.get_flags(), '')
        self.assertEqual(msg_returned.get_payload(), '1\n')
        msg2 = mailbox.MaildirMessage(self._template % 2)
        msg2.set_info('2,S')
        self._box[key] = msg2
        self._box[key] = self._template % 3
        msg_returned = self._box.get_message(key)
        self.assertEqual(msg_returned.get_subdir(), 'new')
        self.assertEqual(msg_returned.get_flags(), 'S')
        self.assertEqual(msg_returned.get_payload(), '3\n') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_mailbox.py

示例2: test_flags

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_flags(self):
        # Use get_flags(), set_flags(), add_flag(), remove_flag()
        msg = mailbox.MaildirMessage(_sample_message)
        self.assertEqual(msg.get_flags(), '')
        self.assertEqual(msg.get_subdir(), 'new')
        msg.set_flags('F')
        self.assertEqual(msg.get_subdir(), 'new')
        self.assertEqual(msg.get_flags(), 'F')
        msg.set_flags('SDTP')
        self.assertEqual(msg.get_flags(), 'DPST')
        msg.add_flag('FT')
        self.assertEqual(msg.get_flags(), 'DFPST')
        msg.remove_flag('TDRP')
        self.assertEqual(msg.get_flags(), 'FS')
        self.assertEqual(msg.get_subdir(), 'new')
        self._check_sample(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_mailbox.py

示例3: test_info_and_flags

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_info_and_flags(self):
        # Test interaction of info and flag methods
        msg = mailbox.MaildirMessage(_sample_message)
        self.assertEqual(msg.get_info(), '')
        msg.set_flags('SF')
        self.assertEqual(msg.get_flags(), 'FS')
        self.assertEqual(msg.get_info(), '2,FS')
        msg.set_info('1,')
        self.assertEqual(msg.get_flags(), '')
        self.assertEqual(msg.get_info(), '1,')
        msg.remove_flag('RPT')
        self.assertEqual(msg.get_flags(), '')
        self.assertEqual(msg.get_info(), '1,')
        msg.add_flag('D')
        self.assertEqual(msg.get_flags(), 'D')
        self.assertEqual(msg.get_info(), '2,D')
        self._check_sample(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_mailbox.py

示例4: test_babyl_to_maildir

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_babyl_to_maildir(self):
        # Convert BabylMessage to MaildirMessage
        pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'),
                 ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'),
                 ('resent', 'PS'))
        for setting, result in pairs:
            msg = mailbox.BabylMessage(_sample_message)
            msg.add_label(setting)
            self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result)
            self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
        msg = mailbox.BabylMessage(_sample_message)
        for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded',
                      'edited', 'resent'):
            msg.add_label(label)
        self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT')
        self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_mailbox.py

示例5: test_add_MM

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_add_MM(self):
        # Add a MaildirMessage instance
        msg = mailbox.MaildirMessage(self._template % 0)
        msg.set_subdir('cur')
        msg.set_info('foo')
        key = self._box.add(msg)
        self.assertTrue(os.path.exists(os.path.join(self._path, 'cur', '%s%sfoo' %
                                                 (key, self._box.colon)))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_mailbox.py

示例6: test_get_MM

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_get_MM(self):
        # Get a MaildirMessage instance
        msg = mailbox.MaildirMessage(self._template % 0)
        msg.set_subdir('cur')
        msg.set_flags('RF')
        key = self._box.add(msg)
        msg_returned = self._box.get_message(key)
        self.assertIsInstance(msg_returned, mailbox.MaildirMessage)
        self.assertEqual(msg_returned.get_subdir(), 'cur')
        self.assertEqual(msg_returned.get_flags(), 'FR') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_mailbox.py

示例7: test_consistent_factory

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_consistent_factory(self):
        # Add a message.
        msg = mailbox.MaildirMessage(self._template % 0)
        msg.set_subdir('cur')
        msg.set_flags('RF')
        key = self._box.add(msg)

        # Create new mailbox with
        class FakeMessage(mailbox.MaildirMessage):
            pass
        box = mailbox.Maildir(self._path, factory=FakeMessage)
        box.colon = self._box.colon
        msg2 = box.get_message(key)
        self.assertIsInstance(msg2, FakeMessage) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_mailbox.py

示例8: test_file_permissions

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_file_permissions(self):
        # Verify that message files are created without execute permissions
        msg = mailbox.MaildirMessage(self._template % 0)
        orig_umask = os.umask(0)
        try:
            key = self._box.add(msg)
        finally:
            os.umask(orig_umask)
        path = os.path.join(self._path, self._box._lookup(key))
        mode = os.stat(path).st_mode
        self.assertEqual(mode & 0111, 0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_mailbox.py

示例9: test_subdir

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_subdir(self):
        # Use get_subdir() and set_subdir()
        msg = mailbox.MaildirMessage(_sample_message)
        self.assertEqual(msg.get_subdir(), 'new')
        msg.set_subdir('cur')
        self.assertEqual(msg.get_subdir(), 'cur')
        msg.set_subdir('new')
        self.assertEqual(msg.get_subdir(), 'new')
        self.assertRaises(ValueError, lambda: msg.set_subdir('tmp'))
        self.assertEqual(msg.get_subdir(), 'new')
        msg.set_subdir('new')
        self.assertEqual(msg.get_subdir(), 'new')
        self._check_sample(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_mailbox.py

示例10: test_date

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_date(self):
        # Use get_date() and set_date()
        msg = mailbox.MaildirMessage(_sample_message)
        diff = msg.get_date() - time.time()
        self.assertLess(abs(diff), 60, diff)
        msg.set_date(0.0)
        self.assertEqual(msg.get_date(), 0.0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_mailbox.py

示例11: test_info

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_info(self):
        # Use get_info() and set_info()
        msg = mailbox.MaildirMessage(_sample_message)
        self.assertEqual(msg.get_info(), '')
        msg.set_info('1,foo=bar')
        self.assertEqual(msg.get_info(), '1,foo=bar')
        self.assertRaises(TypeError, lambda: msg.set_info(None))
        self._check_sample(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_mailbox.py

示例12: test_x_to_plain

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [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

示例13: test_x_to_invalid

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [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

示例14: test_maildir_to_maildir

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [as 别名]
def test_maildir_to_maildir(self):
        # Convert MaildirMessage to MaildirMessage
        msg_maildir = mailbox.MaildirMessage(_sample_message)
        msg_maildir.set_flags('DFPRST')
        msg_maildir.set_subdir('cur')
        date = msg_maildir.get_date()
        msg = mailbox.MaildirMessage(msg_maildir)
        self._check_sample(msg)
        self.assertEqual(msg.get_flags(), 'DFPRST')
        self.assertEqual(msg.get_subdir(), 'cur')
        self.assertEqual(msg.get_date(), date) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_mailbox.py

示例15: test_maildir_to_mboxmmdf

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import MaildirMessage [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


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