本文整理汇总了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.
示例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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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()
示例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.
示例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())
示例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())
示例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())
示例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)
示例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)
示例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)