Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Static Private Attributes
test.test_mailbox.TestMaildirMessage Class Reference
Inheritance diagram for test.test_mailbox.TestMaildirMessage:
Inheritance graph
[legend]
Collaboration diagram for test.test_mailbox.TestMaildirMessage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_subdir
def test_flags
def test_date
def test_info
def test_info_and_flags
def setUp
def tearDown
def test_initialize_with_eMM
def test_initialize_with_string
def test_initialize_with_file
def test_initialize_with_binary_file
def test_initialize_with_nothing
def test_initialize_incorrectly
def test_become_message
def test_explain_to

Private Member Functions

def _post_initialize_hook

Static Private Attributes

 _factory = mailbox.MaildirMessage

Detailed Description

Definition at line 1322 of file test_mailbox.py.


Member Function Documentation

Reimplemented from test.test_mailbox.TestMessage.

Definition at line 1326 of file test_mailbox.py.

01326 
01327     def _post_initialize_hook(self, msg):
01328         self.assertEqual(msg._subdir, 'new')
01329         self.assertEqual(msg._info, '')

Here is the call graph for this function:

def test.test_mailbox.TestMessage.setUp (   self) [inherited]

Definition at line 1246 of file test_mailbox.py.

01246 
01247     def setUp(self):
01248         self._path = support.TESTFN

Here is the caller graph for this function:

def test.test_mailbox.TestMessage.tearDown (   self) [inherited]

Definition at line 1249 of file test_mailbox.py.

01249 
01250     def tearDown(self):
01251         self._delete_recursively(self._path)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1298 of file test_mailbox.py.

01298 
01299     def test_become_message(self):
01300         # Take on the state of another message
01301         eMM = email.message_from_string(_sample_message)
01302         msg = self._factory()
01303         msg._become_message(eMM)
01304         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1361 of file test_mailbox.py.

01361 
01362     def test_date(self):
01363         # Use get_date() and set_date()
01364         msg = mailbox.MaildirMessage(_sample_message)
01365         self.assertLess(abs(msg.get_date() - time.time()), 60)
01366         msg.set_date(0.0)
01367         self.assertEqual(msg.get_date(), 0.0)

Here is the call graph for this function:

Definition at line 1305 of file test_mailbox.py.

01305 
01306     def test_explain_to(self):
01307         # Copy self's format-specific data to other message formats.
01308         # This test is superficial; better ones are in TestMessageConversion.
01309         msg = self._factory()
01310         for class_ in (mailbox.Message, mailbox.MaildirMessage,
01311                        mailbox.mboxMessage, mailbox.MHMessage,
01312                        mailbox.BabylMessage, mailbox.MMDFMessage):
01313             other_msg = class_()
01314             msg._explain_to(other_msg)
01315         other_msg = email.message.Message()
01316         self.assertRaises(TypeError, lambda: msg._explain_to(other_msg))

Here is the call graph for this function:

Definition at line 1344 of file test_mailbox.py.

01344 
01345     def test_flags(self):
01346         # Use get_flags(), set_flags(), add_flag(), remove_flag()
01347         msg = mailbox.MaildirMessage(_sample_message)
01348         self.assertEqual(msg.get_flags(), '')
01349         self.assertEqual(msg.get_subdir(), 'new')
01350         msg.set_flags('F')
01351         self.assertEqual(msg.get_subdir(), 'new')
01352         self.assertEqual(msg.get_flags(), 'F')
01353         msg.set_flags('SDTP')
01354         self.assertEqual(msg.get_flags(), 'DPST')
01355         msg.add_flag('FT')
01356         self.assertEqual(msg.get_flags(), 'DFPST')
01357         msg.remove_flag('TDRP')
01358         self.assertEqual(msg.get_flags(), 'FS')
01359         self.assertEqual(msg.get_subdir(), 'new')
01360         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1368 of file test_mailbox.py.

01368 
01369     def test_info(self):
01370         # Use get_info() and set_info()
01371         msg = mailbox.MaildirMessage(_sample_message)
01372         self.assertEqual(msg.get_info(), '')
01373         msg.set_info('1,foo=bar')
01374         self.assertEqual(msg.get_info(), '1,foo=bar')
01375         self.assertRaises(TypeError, lambda: msg.set_info(None))
01376         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1377 of file test_mailbox.py.

01377 
01378     def test_info_and_flags(self):
01379         # Test interaction of info and flag methods
01380         msg = mailbox.MaildirMessage(_sample_message)
01381         self.assertEqual(msg.get_info(), '')
01382         msg.set_flags('SF')
01383         self.assertEqual(msg.get_flags(), 'FS')
01384         self.assertEqual(msg.get_info(), '2,FS')
01385         msg.set_info('1,')
01386         self.assertEqual(msg.get_flags(), '')
01387         self.assertEqual(msg.get_info(), '1,')
01388         msg.remove_flag('RPT')
01389         self.assertEqual(msg.get_flags(), '')
01390         self.assertEqual(msg.get_info(), '1,')
01391         msg.add_flag('D')
01392         self.assertEqual(msg.get_flags(), 'D')
01393         self.assertEqual(msg.get_info(), '2,D')
01394         self._check_sample(msg)
01395 

Here is the call graph for this function:

Definition at line 1294 of file test_mailbox.py.

01294 
01295     def test_initialize_incorrectly(self):
01296         # Initialize with invalid argument
01297         self.assertRaises(TypeError, lambda: self._factory(object()))

Here is the call graph for this function:

Definition at line 1274 of file test_mailbox.py.

01274 
01275     def test_initialize_with_binary_file(self):
01276         # Initialize based on contents of binary file
01277         with open(self._path, 'wb+') as f:
01278             f.write(_bytes_sample_message)
01279             f.seek(0)
01280             msg = self._factory(f)
01281             self._post_initialize_hook(msg)
01282             self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1252 of file test_mailbox.py.

01252 
01253     def test_initialize_with_eMM(self):
01254         # Initialize based on email.message.Message instance
01255         eMM = email.message_from_string(_sample_message)
01256         msg = self._factory(eMM)
01257         self._post_initialize_hook(msg)
01258         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1265 of file test_mailbox.py.

01265 
01266     def test_initialize_with_file(self):
01267         # Initialize based on contents of file
01268         with open(self._path, 'w+') as f:
01269             f.write(_sample_message)
01270             f.seek(0)
01271             msg = self._factory(f)
01272             self._post_initialize_hook(msg)
01273             self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1283 of file test_mailbox.py.

01283 
01284     def test_initialize_with_nothing(self):
01285         # Initialize without arguments
01286         msg = self._factory()
01287         self._post_initialize_hook(msg)
01288         self.assertIsInstance(msg, email.message.Message)
01289         self.assertIsInstance(msg, mailbox.Message)
01290         self.assertIsInstance(msg, self._factory)
01291         self.assertEqual(msg.keys(), [])
01292         self.assertFalse(msg.is_multipart())
01293         self.assertEqual(msg.get_payload(), None)

Here is the call graph for this function:

Definition at line 1259 of file test_mailbox.py.

01259 
01260     def test_initialize_with_string(self):
01261         # Initialize based on string
01262         msg = self._factory(_sample_message)
01263         self._post_initialize_hook(msg)
01264         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1330 of file test_mailbox.py.

01330 
01331     def test_subdir(self):
01332         # Use get_subdir() and set_subdir()
01333         msg = mailbox.MaildirMessage(_sample_message)
01334         self.assertEqual(msg.get_subdir(), 'new')
01335         msg.set_subdir('cur')
01336         self.assertEqual(msg.get_subdir(), 'cur')
01337         msg.set_subdir('new')
01338         self.assertEqual(msg.get_subdir(), 'new')
01339         self.assertRaises(ValueError, lambda: msg.set_subdir('tmp'))
01340         self.assertEqual(msg.get_subdir(), 'new')
01341         msg.set_subdir('new')
01342         self.assertEqual(msg.get_subdir(), 'new')
01343         self._check_sample(msg)

Here is the call graph for this function:


Member Data Documentation

Reimplemented from test.test_mailbox.TestMessage.

Definition at line 1324 of file test_mailbox.py.


The documentation for this class was generated from the following file: