Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_add
def test_add_invalid_8bit_bytes_header
def test_invalid_nonascii_header_as_string
def test_add_nonascii_string_header_raises
def test_add_that_raises_leaves_mailbox_empty
def test_add_8bit_body
def test_add_binary_file
def test_add_binary_nonascii_file
def test_add_text_file_warns
def test_add_StringIO_warns
def test_add_nonascii_StringIO_raises
def test_remove
def test_delitem
def test_discard
def test_get
def test_getitem
def test_get_message
def test_get_bytes
def test_get_string
def test_get_file
def test_get_file_can_be_closed_twice
def test_iterkeys
def test_keys
def test_itervalues
def test_iter
def test_values
def test_iteritems
def test_items
def test_contains
def test_len
def test_set_item
def test_clear
def test_pop
def test_popitem
def test_update
def test_flush
def test_lock_unlock
def test_close
def test_dump_message

Static Public Attributes

 maxDiff = None

Private Member Functions

def _test_remove_or_delitem
def _check_iteration
def _test_flush_or_close
def _get_lock_path

Private Attributes

 _path
 _box

Static Private Attributes

 _factory = None
string _template = 'From: foo\n\n%s'
tuple _nonascii_msg
tuple _non_latin_bin_msg

Detailed Description

Definition at line 51 of file test_mailbox.py.


Member Function Documentation

def test.test_mailbox.TestMailbox._check_iteration (   self,
  method,
  do_keys,
  do_values,
  repetitions = 10 
) [private]

Definition at line 338 of file test_mailbox.py.

00338 
00339     def _check_iteration(self, method, do_keys, do_values, repetitions=10):
00340         for value in method():
00341             self.fail("Not empty")
00342         keys, values = [], []
00343         for i in range(repetitions):
00344             keys.append(self._box.add(self._template % i))
00345             values.append(self._template % i)
00346         if do_keys and not do_values:
00347             returned_keys = list(method())
00348         elif do_values and not do_keys:
00349             returned_values = list(method())
00350         else:
00351             returned_keys, returned_values = [], []
00352             for key, value in method():
00353                 returned_keys.append(key)
00354                 returned_values.append(value)
00355         if do_keys:
00356             self.assertEqual(len(keys), len(returned_keys))
00357             self.assertEqual(set(keys), set(returned_keys))
00358         if do_values:
00359             count = 0
00360             for value in returned_values:
00361                 self.assertEqual(value['from'], 'foo')
00362                 self.assertLess(int(value.get_payload()), repetitions)
00363                 count += 1
00364             self.assertEqual(len(values), count)

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in test.test_mailbox.TestMH.

Definition at line 547 of file test_mailbox.py.

00547 
00548     def _get_lock_path(self):
00549         # Return the path of the dot lock file. May be overridden.
00550         return self._path + '.lock'
00551 

Here is the caller graph for this function:

def test.test_mailbox.TestMailbox._test_flush_or_close (   self,
  method,
  should_call_close 
) [private]

Definition at line 519 of file test_mailbox.py.

00519 
00520     def _test_flush_or_close(self, method, should_call_close):
00521         contents = [self._template % i for i in range(3)]
00522         self._box.add(contents[0])
00523         self._box.add(contents[1])
00524         self._box.add(contents[2])
00525         oldbox = self._box
00526         method()
00527         if should_call_close:
00528             self._box.close()
00529         self._box = self._factory(self._path)
00530         keys = self._box.keys()
00531         self.assertEqual(len(keys), 3)
00532         for key in keys:
00533             self.assertIn(self._box.get_string(key), contents)
00534         oldbox.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_mailbox.TestMailbox._test_remove_or_delitem (   self,
  method 
) [private]

Definition at line 202 of file test_mailbox.py.

00202 
00203     def _test_remove_or_delitem(self, method):
00204         # (Used by test_remove() and test_delitem().)
00205         key0 = self._box.add(self._template % 0)
00206         key1 = self._box.add(self._template % 1)
00207         self.assertEqual(len(self._box), 2)
00208         method(key0)
00209         self.assertEqual(len(self._box), 1)
00210         self.assertRaises(KeyError, lambda: self._box[key0])
00211         self.assertRaises(KeyError, lambda: method(key0))
00212         self.assertEqual(self._box.get_string(key1), self._template % 1)
00213         key2 = self._box.add(self._template % 2)
00214         self.assertEqual(len(self._box), 2)
00215         method(key2)
00216         self.assertEqual(len(self._box), 1)
00217         self.assertRaises(KeyError, lambda: self._box[key2])
00218         self.assertRaises(KeyError, lambda: method(key2))
00219         self.assertEqual(self._box.get_string(key1), self._template % 1)
00220         method(key1)
00221         self.assertEqual(len(self._box), 0)
00222         self.assertRaises(KeyError, lambda: self._box[key1])
00223         self.assertRaises(KeyError, lambda: method(key1))

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in test.test_mailbox.TestMaildir.

Definition at line 58 of file test_mailbox.py.

00058 
00059     def setUp(self):
00060         self._path = support.TESTFN
00061         self._delete_recursively(self._path)
00062         self._box = self._factory(self._path)

Here is the caller graph for this function:

Reimplemented in test.test_mailbox.TestBabyl, and test.test_mailbox._TestMboxMMDF.

Definition at line 63 of file test_mailbox.py.

00063 
00064     def tearDown(self):
00065         self._box.close()
00066         self._delete_recursively(self._path)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 67 of file test_mailbox.py.

00067 
00068     def test_add(self):
00069         # Add copies of a sample message
00070         keys = []
00071         keys.append(self._box.add(self._template % 0))
00072         self.assertEqual(len(self._box), 1)
00073         keys.append(self._box.add(mailbox.Message(_sample_message)))
00074         self.assertEqual(len(self._box), 2)
00075         keys.append(self._box.add(email.message_from_string(_sample_message)))
00076         self.assertEqual(len(self._box), 3)
00077         keys.append(self._box.add(io.BytesIO(_bytes_sample_message)))
00078         self.assertEqual(len(self._box), 4)
00079         keys.append(self._box.add(_sample_message))
00080         self.assertEqual(len(self._box), 5)
00081         keys.append(self._box.add(_bytes_sample_message))
00082         self.assertEqual(len(self._box), 6)
00083         with self.assertWarns(DeprecationWarning):
00084             keys.append(self._box.add(
00085                 io.TextIOWrapper(io.BytesIO(_bytes_sample_message))))
00086         self.assertEqual(len(self._box), 7)
00087         self.assertEqual(self._box.get_string(keys[0]), self._template % 0)
00088         for i in (1, 2, 3, 4, 5, 6):
00089             self._check_sample(self._box[keys[i]])

Here is the call graph for this function:

Definition at line 139 of file test_mailbox.py.

00139 
00140     def test_add_8bit_body(self):
00141         key = self._box.add(self._non_latin_bin_msg)
00142         self.assertEqual(self._box.get_bytes(key),
00143                          self._non_latin_bin_msg)
00144         with self._box.get_file(key) as f:
00145             self.assertEqual(f.read(),
00146                              self._non_latin_bin_msg.replace(b'\n',
00147                                 os.linesep.encode()))
00148         self.assertEqual(self._box[key].get_payload(),
00149                         "Да, они летят.\n")

Here is the call graph for this function:

Definition at line 150 of file test_mailbox.py.

00150 
00151     def test_add_binary_file(self):
00152         with tempfile.TemporaryFile('wb+') as f:
00153             f.write(_bytes_sample_message)
00154             f.seek(0)
00155             key = self._box.add(f)
00156         # See issue 11062
00157         if not isinstance(self._box, mailbox.Babyl):
00158             self.assertEqual(self._box.get_bytes(key).split(b'\n'),
00159                 _bytes_sample_message.split(b'\n'))

Here is the call graph for this function:

Definition at line 160 of file test_mailbox.py.

00160 
00161     def test_add_binary_nonascii_file(self):
00162         with tempfile.TemporaryFile('wb+') as f:
00163             f.write(self._non_latin_bin_msg)
00164             f.seek(0)
00165             key = self._box.add(f)
00166         # See issue 11062
00167         if not isinstance(self._box, mailbox.Babyl):
00168             self.assertEqual(self._box.get_bytes(key).split(b'\n'),
00169                 self._non_latin_bin_msg.split(b'\n'))

Here is the call graph for this function:

Definition at line 97 of file test_mailbox.py.

00097 
00098     def test_add_invalid_8bit_bytes_header(self):
00099         key = self._box.add(self._nonascii_msg.encode('latin1'))
00100         self.assertEqual(len(self._box), 1)
00101         self.assertEqual(self._box.get_bytes(key),
00102             self._nonascii_msg.encode('latin1'))

Here is the call graph for this function:

Definition at line 110 of file test_mailbox.py.

00110 
00111     def test_add_nonascii_string_header_raises(self):
00112         with self.assertRaisesRegex(ValueError, "ASCII-only"):
00113             self._box.add(self._nonascii_msg)
00114         self._box.flush()
00115         self.assertEqual(len(self._box), 0)
00116         self.assertMailboxEmpty()

Here is the call graph for this function:

Definition at line 186 of file test_mailbox.py.

00186 
00187     def test_add_nonascii_StringIO_raises(self):
00188         with self.assertWarns(DeprecationWarning):
00189             with self.assertRaisesRegex(ValueError, "ASCII-only"):
00190                 self._box.add(io.StringIO(self._nonascii_msg))
00191         self.assertEqual(len(self._box), 0)
00192         self._box.close()
00193         self.assertMailboxEmpty()

Here is the call graph for this function:

Definition at line 181 of file test_mailbox.py.

00181 
00182     def test_add_StringIO_warns(self):
00183         with self.assertWarns(DeprecationWarning):
00184             key = self._box.add(io.StringIO(self._template % "0"))
00185         self.assertEqual(self._box.get_string(key), self._template % "0")

Here is the call graph for this function:

Definition at line 170 of file test_mailbox.py.

00170 
00171     def test_add_text_file_warns(self):
00172         with tempfile.TemporaryFile('w+') as f:
00173             f.write(_sample_message)
00174             f.seek(0)
00175             with self.assertWarns(DeprecationWarning):
00176                 key = self._box.add(f)
00177         # See issue 11062
00178         if not isinstance(self._box, mailbox.Babyl):
00179             self.assertEqual(self._box.get_bytes(key).split(b'\n'),
00180                 _bytes_sample_message.split(b'\n'))

Here is the call graph for this function:

Definition at line 117 of file test_mailbox.py.

00117 
00118     def test_add_that_raises_leaves_mailbox_empty(self):
00119         # XXX This test will start failing when Message learns to handle
00120         # non-ASCII string headers, and a different internal failure will
00121         # need to be found or manufactured.
00122         with self.assertRaises(ValueError):
00123             self._box.add(email.message_from_string("From: Alphöso"))
00124         self.assertEqual(len(self._box), 0)
00125         self._box.close()
00126         self.assertMailboxEmpty()

Here is the call graph for this function:

def test.test_mailbox.TestMailbox.test_clear (   self,
  iterations = 10 
)

Definition at line 423 of file test_mailbox.py.

00423 
00424     def test_clear(self, iterations=10):
00425         # Remove all messages using clear()
00426         keys = []
00427         for i in range(iterations):
00428             self._box.add(self._template % i)
00429         for i, key in enumerate(keys):
00430             self.assertEqual(self._box.get_string(key), self._template % i)
00431         self._box.clear()
00432         self.assertEqual(len(self._box), 0)
00433         for i, key in enumerate(keys):
00434             self.assertRaises(KeyError, lambda: self._box.get_string(key))

Here is the call graph for this function:

Definition at line 515 of file test_mailbox.py.

00515 
00516     def test_close(self):
00517         # Close mailbox and flush changes to disk
00518         self._test_flush_or_close(self._box.close, False)

Here is the call graph for this function:

Definition at line 365 of file test_mailbox.py.

00365 
00366     def test_contains(self):
00367         # Check existence of keys using __contains__()
00368         self.assertNotIn('foo', self._box)
00369         key0 = self._box.add(self._template % 0)
00370         self.assertIn(key0, self._box)
00371         self.assertNotIn('foo', self._box)
00372         key1 = self._box.add(self._template % 1)
00373         self.assertIn(key1, self._box)
00374         self.assertIn(key0, self._box)
00375         self.assertNotIn('foo', self._box)
00376         self._box.remove(key0)
00377         self.assertNotIn(key0, self._box)
00378         self.assertIn(key1, self._box)
00379         self.assertNotIn('foo', self._box)
00380         self._box.remove(key1)
00381         self.assertNotIn(key1, self._box)
00382         self.assertNotIn(key0, self._box)
00383         self.assertNotIn('foo', self._box)

Here is the call graph for this function:

Definition at line 198 of file test_mailbox.py.

00198 
00199     def test_delitem(self):
00200         # Remove messages using __delitem__()
00201         self._test_remove_or_delitem(self._box.__delitem__)

Here is the call graph for this function:

def test.test_mailbox.TestMailbox.test_discard (   self,
  repetitions = 10 
)

Definition at line 224 of file test_mailbox.py.

00224 
00225     def test_discard(self, repetitions=10):
00226         # Discard messages
00227         key0 = self._box.add(self._template % 0)
00228         key1 = self._box.add(self._template % 1)
00229         self.assertEqual(len(self._box), 2)
00230         self._box.discard(key0)
00231         self.assertEqual(len(self._box), 1)
00232         self.assertRaises(KeyError, lambda: self._box[key0])
00233         self._box.discard(key0)
00234         self.assertEqual(len(self._box), 1)
00235         self.assertRaises(KeyError, lambda: self._box[key0])

Here is the call graph for this function:

Definition at line 535 of file test_mailbox.py.

00535 
00536     def test_dump_message(self):
00537         # Write message representations to disk
00538         for input in (email.message_from_string(_sample_message),
00539                       _sample_message, io.BytesIO(_bytes_sample_message)):
00540             output = io.BytesIO()
00541             self._box._dump_message(input, output)
00542             self.assertEqual(output.getvalue(),
00543                 _bytes_sample_message.replace(b'\n', os.linesep.encode()))
00544         output = io.BytesIO()
00545         self.assertRaises(TypeError,
00546                           lambda: self._box._dump_message(None, output))

Here is the call graph for this function:

Definition at line 503 of file test_mailbox.py.

00503 
00504     def test_flush(self):
00505         # Write changes to disk
00506         self._test_flush_or_close(self._box.flush, True)

Here is the call graph for this function:

Definition at line 236 of file test_mailbox.py.

00236 
00237     def test_get(self):
00238         # Retrieve messages using get()
00239         key0 = self._box.add(self._template % 0)
00240         msg = self._box.get(key0)
00241         self.assertEqual(msg['from'], 'foo')
00242         self.assertEqual(msg.get_payload(), '0')
00243         self.assertIs(self._box.get('foo'), None)
00244         self.assertIs(self._box.get('foo', False), False)
00245         self._box.close()
00246         self._box = self._factory(self._path)
00247         key1 = self._box.add(self._template % 1)
00248         msg = self._box.get(key1)
00249         self.assertEqual(msg['from'], 'foo')
00250         self.assertEqual(msg.get_payload(), '1')

Here is the call graph for this function:

Definition at line 271 of file test_mailbox.py.

00271 
00272     def test_get_bytes(self):
00273         # Get bytes representations of messages
00274         key0 = self._box.add(self._template % 0)
00275         key1 = self._box.add(_sample_message)
00276         self.assertEqual(self._box.get_bytes(key0),
00277             (self._template % 0).encode('ascii'))
00278         self.assertEqual(self._box.get_bytes(key1), _bytes_sample_message)

Here is the call graph for this function:

Definition at line 287 of file test_mailbox.py.

00287 
00288     def test_get_file(self):
00289         # Get file representations of messages
00290         key0 = self._box.add(self._template % 0)
00291         key1 = self._box.add(_sample_message)
00292         with self._box.get_file(key0) as file:
00293             data0 = file.read()
00294         with self._box.get_file(key1) as file:
00295             data1 = file.read()
00296         self.assertEqual(data0.decode('ascii').replace(os.linesep, '\n'),
00297                          self._template % 0)
00298         self.assertEqual(data1.decode('ascii').replace(os.linesep, '\n'),
00299                          _sample_message)

Here is the call graph for this function:

Definition at line 300 of file test_mailbox.py.

00300 
00301     def test_get_file_can_be_closed_twice(self):
00302         # Issue 11700
00303         key = self._box.add(_sample_message)
00304         f = self._box.get_file(key)
00305         f.close()
00306         f.close()

Definition at line 261 of file test_mailbox.py.

00261 
00262     def test_get_message(self):
00263         # Get Message representations of messages
00264         key0 = self._box.add(self._template % 0)
00265         key1 = self._box.add(_sample_message)
00266         msg0 = self._box.get_message(key0)
00267         self.assertIsInstance(msg0, mailbox.Message)
00268         self.assertEqual(msg0['from'], 'foo')
00269         self.assertEqual(msg0.get_payload(), '0')
00270         self._check_sample(self._box.get_message(key1))

Here is the call graph for this function:

Definition at line 279 of file test_mailbox.py.

00279 
00280     def test_get_string(self):
00281         # Get string representations of messages
00282         key0 = self._box.add(self._template % 0)
00283         key1 = self._box.add(_sample_message)
00284         self.assertEqual(self._box.get_string(key0), self._template % 0)
00285         self.assertEqual(self._box.get_string(key1).split('\n'),
00286                          _sample_message.split('\n'))

Here is the call graph for this function:

Definition at line 251 of file test_mailbox.py.

00251 
00252     def test_getitem(self):
00253         # Retrieve message using __getitem__()
00254         key0 = self._box.add(self._template % 0)
00255         msg = self._box[key0]
00256         self.assertEqual(msg['from'], 'foo')
00257         self.assertEqual(msg.get_payload(), '0')
00258         self.assertRaises(KeyError, lambda: self._box['foo'])
00259         self._box.discard(key0)
00260         self.assertRaises(KeyError, lambda: self._box[key0])

Here is the call graph for this function:

Definition at line 103 of file test_mailbox.py.

00103 
00104     def test_invalid_nonascii_header_as_string(self):
00105         subj = self._nonascii_msg.splitlines()[1]
00106         key = self._box.add(subj.encode('latin1'))
00107         self.assertEqual(self._box.get_string(key),
00108             'Subject: =?unknown-8bit?b?RmFsaW5hcHThciBo4Xpob3pzeuFsbO104XNz'
00109             'YWwuIE3hciByZW5kZWx06Ww/?=\n\n')

Here is the call graph for this function:

Definition at line 334 of file test_mailbox.py.

00334 
00335     def test_items(self):
00336         # Get keys and values using items()
00337         self._check_iteration(self._box.items, do_keys=True, do_values=True)

Here is the call graph for this function:

Definition at line 320 of file test_mailbox.py.

00320 
00321     def test_iter(self):
00322         # Get values using __iter__()
00323         self._check_iteration(self._box.__iter__, do_keys=False,
00324                               do_values=True)

Here is the call graph for this function:

Definition at line 329 of file test_mailbox.py.

00329 
00330     def test_iteritems(self):
00331         # Get keys and values using iteritems()
00332         self._check_iteration(self._box.items, do_keys=True,
00333                               do_values=True)

Here is the call graph for this function:

Definition at line 307 of file test_mailbox.py.

00307 
00308     def test_iterkeys(self):
00309         # Get keys using iterkeys()
00310         self._check_iteration(self._box.keys, do_keys=True, do_values=False)

Here is the call graph for this function:

Definition at line 315 of file test_mailbox.py.

00315 
00316     def test_itervalues(self):
00317         # Get values using itervalues()
00318         self._check_iteration(self._box.values, do_keys=False,
00319                               do_values=True)

Here is the call graph for this function:

Definition at line 311 of file test_mailbox.py.

00311 
00312     def test_keys(self):
00313         # Get keys using keys()
00314         self._check_iteration(self._box.keys, do_keys=True, do_values=False)

Here is the call graph for this function:

def test.test_mailbox.TestMailbox.test_len (   self,
  repetitions = 10 
)

Definition at line 384 of file test_mailbox.py.

00384 
00385     def test_len(self, repetitions=10):
00386         # Get message count
00387         keys = []
00388         for i in range(repetitions):
00389             self.assertEqual(len(self._box), i)
00390             keys.append(self._box.add(self._template % i))
00391             self.assertEqual(len(self._box), i + 1)
00392         for i in range(repetitions):
00393             self.assertEqual(len(self._box), repetitions - i)
00394             self._box.remove(keys[i])
00395             self.assertEqual(len(self._box), repetitions - i - 1)

Here is the call graph for this function:

Reimplemented in test.test_mailbox.TestMaildir.

Definition at line 507 of file test_mailbox.py.

00507 
00508     def test_lock_unlock(self):
00509         # Lock and unlock the mailbox
00510         self.assertFalse(os.path.exists(self._get_lock_path()))
00511         self._box.lock()
00512         self.assertTrue(os.path.exists(self._get_lock_path()))
00513         self._box.unlock()
00514         self.assertFalse(os.path.exists(self._get_lock_path()))

Here is the call graph for this function:

Definition at line 435 of file test_mailbox.py.

00435 
00436     def test_pop(self):
00437         # Get and remove a message using pop()
00438         key0 = self._box.add(self._template % 0)
00439         self.assertIn(key0, self._box)
00440         key1 = self._box.add(self._template % 1)
00441         self.assertIn(key1, self._box)
00442         self.assertEqual(self._box.pop(key0).get_payload(), '0')
00443         self.assertNotIn(key0, self._box)
00444         self.assertIn(key1, self._box)
00445         key2 = self._box.add(self._template % 2)
00446         self.assertIn(key2, self._box)
00447         self.assertEqual(self._box.pop(key2).get_payload(), '2')
00448         self.assertNotIn(key2, self._box)
00449         self.assertIn(key1, self._box)
00450         self.assertEqual(self._box.pop(key1).get_payload(), '1')
00451         self.assertNotIn(key1, self._box)
00452         self.assertEqual(len(self._box), 0)

Here is the call graph for this function:

def test.test_mailbox.TestMailbox.test_popitem (   self,
  iterations = 10 
)

Definition at line 453 of file test_mailbox.py.

00453 
00454     def test_popitem(self, iterations=10):
00455         # Get and remove an arbitrary (key, message) using popitem()
00456         keys = []
00457         for i in range(10):
00458             keys.append(self._box.add(self._template % i))
00459         seen = []
00460         for i in range(10):
00461             key, msg = self._box.popitem()
00462             self.assertIn(key, keys)
00463             self.assertNotIn(key, seen)
00464             seen.append(key)
00465             self.assertEqual(int(msg.get_payload()), keys.index(key))
00466         self.assertEqual(len(self._box), 0)
00467         for key in keys:
00468             self.assertRaises(KeyError, lambda: self._box[key])

Here is the call graph for this function:

Definition at line 194 of file test_mailbox.py.

00194 
00195     def test_remove(self):
00196         # Remove messages using remove()
00197         self._test_remove_or_delitem(self._box.remove)

Here is the call graph for this function:

Definition at line 396 of file test_mailbox.py.

00396 
00397     def test_set_item(self):
00398         # Modify messages using __setitem__()
00399         key0 = self._box.add(self._template % 'original 0')
00400         self.assertEqual(self._box.get_string(key0),
00401                          self._template % 'original 0')
00402         key1 = self._box.add(self._template % 'original 1')
00403         self.assertEqual(self._box.get_string(key1),
00404                          self._template % 'original 1')
00405         self._box[key0] = self._template % 'changed 0'
00406         self.assertEqual(self._box.get_string(key0),
00407                          self._template % 'changed 0')
00408         self._box[key1] = self._template % 'changed 1'
00409         self.assertEqual(self._box.get_string(key1),
00410                          self._template % 'changed 1')
00411         self._box[key0] = _sample_message
00412         self._check_sample(self._box[key0])
00413         self._box[key1] = self._box[key0]
00414         self._check_sample(self._box[key1])
00415         self._box[key0] = self._template % 'original 0'
00416         self.assertEqual(self._box.get_string(key0),
00417                      self._template % 'original 0')
00418         self._check_sample(self._box[key1])
00419         self.assertRaises(KeyError,
00420                           lambda: self._box.__setitem__('foo', 'bar'))
00421         self.assertRaises(KeyError, lambda: self._box['foo'])
00422         self.assertEqual(len(self._box), 2)

Here is the call graph for this function:

Definition at line 469 of file test_mailbox.py.

00469 
00470     def test_update(self):
00471         # Modify multiple messages using update()
00472         key0 = self._box.add(self._template % 'original 0')
00473         key1 = self._box.add(self._template % 'original 1')
00474         key2 = self._box.add(self._template % 'original 2')
00475         self._box.update({key0: self._template % 'changed 0',
00476                           key2: _sample_message})
00477         self.assertEqual(len(self._box), 3)
00478         self.assertEqual(self._box.get_string(key0),
00479                      self._template % 'changed 0')
00480         self.assertEqual(self._box.get_string(key1),
00481                      self._template % 'original 1')
00482         self._check_sample(self._box[key2])
00483         self._box.update([(key2, self._template % 'changed 2'),
00484                     (key1, self._template % 'changed 1'),
00485                     (key0, self._template % 'original 0')])
00486         self.assertEqual(len(self._box), 3)
00487         self.assertEqual(self._box.get_string(key0),
00488                      self._template % 'original 0')
00489         self.assertEqual(self._box.get_string(key1),
00490                      self._template % 'changed 1')
00491         self.assertEqual(self._box.get_string(key2),
00492                      self._template % 'changed 2')
00493         self.assertRaises(KeyError,
00494                           lambda: self._box.update({'foo': 'bar',
00495                                           key0: self._template % "changed 0"}))
00496         self.assertEqual(len(self._box), 3)
00497         self.assertEqual(self._box.get_string(key0),
00498                      self._template % "changed 0")
00499         self.assertEqual(self._box.get_string(key1),
00500                      self._template % "changed 1")
00501         self.assertEqual(self._box.get_string(key2),
00502                      self._template % "changed 2")

Here is the call graph for this function:

Definition at line 325 of file test_mailbox.py.

00325 
00326     def test_values(self):
00327         # Get values using values()
00328         self._check_iteration(self._box.values, do_keys=False, do_values=True)

Here is the call graph for this function:


Member Data Documentation

test.test_mailbox.TestMailbox._factory = None [static, private]
Initial value:
textwrap.dedent("""\
    From: foo@bar.com    To: báz    Subject: Maintenant je vous présente mon collègue, le pouf célèbre    \tJean de Baddie    Mime-Version: 1.0    Content-Type: text/plain; charset="utf-8"    Content-Transfer-Encoding: 8bit    Да, они летят.    """)

Definition at line 127 of file test_mailbox.py.

Initial value:
textwrap.dedent("""\
        From: foo        Subject: Falinaptár házhozszállítással. Már rendeltél?        0        """)

Definition at line 90 of file test_mailbox.py.

Definition at line 59 of file test_mailbox.py.

Definition at line 56 of file test_mailbox.py.

Definition at line 53 of file test_mailbox.py.


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