Back to index

python3.2  3.2.2
Public Member Functions
email.test.test_email.TestIterators Class Reference
Inheritance diagram for email.test.test_email.TestIterators:
Inheritance graph
[legend]
Collaboration diagram for email.test.test_email.TestIterators:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_body_line_iterator
def test_typed_subpart_iterator
def test_typed_subpart_iterator_default_type
def test_pushCR_LF
def ndiffAssertEqual

Detailed Description

Definition at line 2803 of file test_email.py.


Member Function Documentation

def email.test.test_email.TestEmailBase.ndiffAssertEqual (   self,
  first,
  second 
) [inherited]
Like assertEqual except use ndiff for readable output.

Definition at line 57 of file test_email.py.

00057 
00058     def ndiffAssertEqual(self, first, second):
00059         """Like assertEqual except use ndiff for readable output."""
00060         if first != second:
00061             sfirst = str(first)
00062             ssecond = str(second)
00063             rfirst = [repr(line) for line in sfirst.splitlines()]
00064             rsecond = [repr(line) for line in ssecond.splitlines()]
00065             diff = difflib.ndiff(rfirst, rsecond)
00066             raise self.failureException(NL + NL.join(diff))

Here is the call graph for this function:

Definition at line 2804 of file test_email.py.

02804 
02805     def test_body_line_iterator(self):
02806         eq = self.assertEqual
02807         neq = self.ndiffAssertEqual
02808         # First a simple non-multipart message
02809         msg = self._msgobj('msg_01.txt')
02810         it = iterators.body_line_iterator(msg)
02811         lines = list(it)
02812         eq(len(lines), 6)
02813         neq(EMPTYSTRING.join(lines), msg.get_payload())
02814         # Now a more complicated multipart
02815         msg = self._msgobj('msg_02.txt')
02816         it = iterators.body_line_iterator(msg)
02817         lines = list(it)
02818         eq(len(lines), 43)
02819         with openfile('msg_19.txt') as fp:
02820             neq(EMPTYSTRING.join(lines), fp.read())

Here is the call graph for this function:

FeedParser BufferedSubFile.push() assumed it received complete
   line endings.  A CR ending one push() followed by a LF starting
   the next push() added an empty line.

Definition at line 2857 of file test_email.py.

02857 
02858     def test_pushCR_LF(self):
02859         '''FeedParser BufferedSubFile.push() assumed it received complete
02860            line endings.  A CR ending one push() followed by a LF starting
02861            the next push() added an empty line.
02862         '''
02863         imt = [
02864             ("a\r \n",  2),
02865             ("b",       0),
02866             ("c\n",     1),
02867             ("",        0),
02868             ("d\r\n",   1),
02869             ("e\r",     0),
02870             ("\nf",     1),
02871             ("\r\n",    1),
02872           ]
02873         from email.feedparser import BufferedSubFile, NeedMoreData
02874         bsf = BufferedSubFile()
02875         om = []
02876         nt = 0
02877         for il, n in imt:
02878             bsf.push(il)
02879             nt += n
02880             n1 = 0
02881             while True:
02882                 ol = bsf.readline()
02883                 if ol == NeedMoreData:
02884                     break
02885                 om.append(ol)
02886                 n1 += 1
02887             self.assertTrue(n == n1)
02888         self.assertTrue(len(om) == nt)
02889         self.assertTrue(''.join([il for il, n in imt]) == ''.join(om))
02890 
02891 

Here is the call graph for this function:

Definition at line 2821 of file test_email.py.

02821 
02822     def test_typed_subpart_iterator(self):
02823         eq = self.assertEqual
02824         msg = self._msgobj('msg_04.txt')
02825         it = iterators.typed_subpart_iterator(msg, 'text')
02826         lines = []
02827         subparts = 0
02828         for subpart in it:
02829             subparts += 1
02830             lines.append(subpart.get_payload())
02831         eq(subparts, 2)
02832         eq(EMPTYSTRING.join(lines), """\
02833 a simple kind of mirror
02834 to reflect upon our own
02835 a simple kind of mirror
02836 to reflect upon our own
02837 """)

Here is the call graph for this function:

Definition at line 2838 of file test_email.py.

02838 
02839     def test_typed_subpart_iterator_default_type(self):
02840         eq = self.assertEqual
02841         msg = self._msgobj('msg_03.txt')
02842         it = iterators.typed_subpart_iterator(msg, 'text', 'plain')
02843         lines = []
02844         subparts = 0
02845         for subpart in it:
02846             subparts += 1
02847             lines.append(subpart.get_payload())
02848         eq(subparts, 1)
02849         eq(EMPTYSTRING.join(lines), """\
02850 
02851 Hi,
02852 
02853 Do you like this message?
02854 
02855 -Me
02856 """)

Here is the call graph for this function:


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