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


Python mailbox.Maildir方法代码示例

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


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

示例1: test_folder_file_perms

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_folder_file_perms(self):
        # From bug #3228, we want to verify that the file created inside a Maildir
        # subfolder isn't marked as executable.
        if not hasattr(os, "stat") or not hasattr(os, "umask"):
            return

        orig_umask = os.umask(0)
        try:
            subfolder = self._box.add_folder('subfolder')
        finally:
            os.umask(orig_umask)

        path = os.path.join(subfolder._path, 'maildirfolder')
        st = os.stat(path)
        perms = st.st_mode
        self.assertFalse((perms & 0111)) # Execute bits should all be off. 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:18,代码来源:test_mailbox.py

示例2: test_empty_maildir

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_empty_maildir(self):
        """Test an empty maildir mailbox"""
        # Test for regression on bug #117490:
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        self.assertTrue(len(self.mbox) == 0)
        self.assertTrue(self.mbox.next() is None)
        self.assertTrue(self.mbox.next() is None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_old_mailbox.py

示例3: test_nonempty_maildir_cur

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_cur(self):
        self.createMessage("cur")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        self.assertTrue(len(self.mbox) == 1)
        msg = self.mbox.next()
        self.assertTrue(msg is not None)
        msg.fp.close()
        self.assertTrue(self.mbox.next() is None)
        self.assertTrue(self.mbox.next() is None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_old_mailbox.py

示例4: test_nonempty_maildir_new

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_new(self):
        self.createMessage("new")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        self.assertTrue(len(self.mbox) == 1)
        msg = self.mbox.next()
        self.assertTrue(msg is not None)
        msg.fp.close()
        self.assertTrue(self.mbox.next() is None)
        self.assertTrue(self.mbox.next() is None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_old_mailbox.py

示例5: test_nonempty_maildir_both

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_both(self):
        self.createMessage("cur")
        self.createMessage("new")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        self.assertTrue(len(self.mbox) == 2)
        msg = self.mbox.next()
        self.assertTrue(msg is not None)
        msg.fp.close()
        msg = self.mbox.next()
        self.assertTrue(msg is not None)
        msg.fp.close()
        self.assertTrue(self.mbox.next() is None)
        self.assertTrue(self.mbox.next() is None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_old_mailbox.py

示例6: test_consistent_factory

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

示例7: test_initialize_existing

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_initialize_existing(self):
        # Initialize an existing mailbox
        self.tearDown()
        for subdir in '', 'tmp', 'new', 'cur':
            os.mkdir(os.path.normpath(os.path.join(self._path, subdir)))
        self._box = mailbox.Maildir(self._path)
        self._check_basics(factory=rfc822.Message)
        self._box = mailbox.Maildir(self._path, factory=None)
        self._check_basics() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_mailbox.py

示例8: test_lock_unlock

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_lock_unlock(self):
        # Lock and unlock the mailbox. For Maildir, this does nothing.
        self._box.lock()
        self._box.unlock() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_mailbox.py

示例9: test_folder_file_perms

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_folder_file_perms(self):
        # From bug #3228, we want to verify that the file created inside a Maildir
        # subfolder isn't marked as executable.
        orig_umask = os.umask(0)
        try:
            subfolder = self._box.add_folder('subfolder')
        finally:
            os.umask(orig_umask)

        path = os.path.join(subfolder._path, 'maildirfolder')
        st = os.stat(path)
        perms = st.st_mode
        self.assertFalse((perms & 0111)) # Execute bits should all be off. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_mailbox.py

示例10: test_empty_maildir

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_empty_maildir(self):
        """Test an empty maildir mailbox"""
        # Test for regression on bug #117490:
        # Make sure the boxes attribute actually gets set.
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertTrue(hasattr(self.mbox, "boxes"))
        #self.assertEqual(len(self.mbox.boxes), 0)
        self.assertIsNone(self.mbox.next())
        self.assertIsNone(self.mbox.next()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_mailbox.py

示例11: test_nonempty_maildir_cur

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_cur(self):
        self.createMessage("cur")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertEqual(len(self.mbox.boxes), 1)
        msg = self.mbox.next()
        self.assertIsNotNone(msg)
        msg.fp.close()
        self.assertIsNone(self.mbox.next())
        self.assertIsNone(self.mbox.next()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_mailbox.py

示例12: test_nonempty_maildir_both

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_both(self):
        self.createMessage("cur")
        self.createMessage("new")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertEqual(len(self.mbox.boxes), 2)
        msg = self.mbox.next()
        self.assertIsNotNone(msg)
        msg.fp.close()
        msg = self.mbox.next()
        self.assertIsNotNone(msg)
        msg.fp.close()
        self.assertIsNone(self.mbox.next())
        self.assertIsNone(self.mbox.next()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_mailbox.py

示例13: test_empty_maildir

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_empty_maildir(self):
        """Test an empty maildir mailbox"""
        # Test for regression on bug #117490:
        # Make sure the boxes attribute actually gets set.
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertTrue(hasattr(self.mbox, "boxes"))
        #self.assertTrue(len(self.mbox.boxes) == 0)
        self.assertIs(self.mbox.next(), None)
        self.assertIs(self.mbox.next(), None) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:11,代码来源:test_mailbox.py

示例14: test_nonempty_maildir_cur

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_cur(self):
        self.createMessage("cur")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertTrue(len(self.mbox.boxes) == 1)
        msg = self.mbox.next()
        self.assertIsNot(msg, None)
        msg.fp.close()
        self.assertIs(self.mbox.next(), None)
        self.assertIs(self.mbox.next(), None) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:11,代码来源:test_mailbox.py

示例15: test_nonempty_maildir_both

# 需要导入模块: import mailbox [as 别名]
# 或者: from mailbox import Maildir [as 别名]
def test_nonempty_maildir_both(self):
        self.createMessage("cur")
        self.createMessage("new")
        self.mbox = mailbox.Maildir(test_support.TESTFN)
        #self.assertTrue(len(self.mbox.boxes) == 2)
        msg = self.mbox.next()
        self.assertIsNot(msg, None)
        msg.fp.close()
        msg = self.mbox.next()
        self.assertIsNot(msg, None)
        msg.fp.close()
        self.assertIs(self.mbox.next(), None)
        self.assertIs(self.mbox.next(), None) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:15,代码来源:test_mailbox.py


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