Back to index

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

List of all members.

Public Member Functions

def test_parse_missing_minor_type
def test_same_boundary_inner_outer
def test_multipart_no_boundary
def test_invalid_content_type
def test_no_start_boundary
def test_no_separating_blank_line
def test_lying_multipart
def test_missing_start_boundary
def test_first_line_is_continuation_header
def ndiffAssertEqual

Detailed Description

Definition at line 1800 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 1900 of file test_email.py.

01900 
01901     def test_first_line_is_continuation_header(self):
01902         eq = self.assertEqual
01903         m = ' Line 1\nLine 2\nLine 3'
01904         msg = email.message_from_string(m)
01905         eq(msg.keys(), [])
01906         eq(msg.get_payload(), 'Line 2\nLine 3')
01907         eq(len(msg.defects), 1)
01908         self.assertTrue(isinstance(msg.defects[0],
01909                                    errors.FirstHeaderLineIsContinuationDefect))
01910         eq(msg.defects[0].line, ' Line 1\n')
01911 
01912 
01913 
# Test RFC 2047 header encoding and decoding

Here is the call graph for this function:

Definition at line 1827 of file test_email.py.

01827 
01828     def test_invalid_content_type(self):
01829         eq = self.assertEqual
01830         neq = self.ndiffAssertEqual
01831         msg = Message()
01832         # RFC 2045, $5.2 says invalid yields text/plain
01833         msg['Content-Type'] = 'text'
01834         eq(msg.get_content_maintype(), 'text')
01835         eq(msg.get_content_subtype(), 'plain')
01836         eq(msg.get_content_type(), 'text/plain')
01837         # Clear the old value and try something /really/ invalid
01838         del msg['content-type']
01839         msg['Content-Type'] = 'foo'
01840         eq(msg.get_content_maintype(), 'text')
01841         eq(msg.get_content_subtype(), 'plain')
01842         eq(msg.get_content_type(), 'text/plain')
01843         # Still, make sure that the message is idempotently generated
01844         s = StringIO()
01845         g = Generator(s)
01846         g.flatten(msg)
01847         neq(s.getvalue(), 'Content-Type: foo\n\n')

Here is the call graph for this function:

Definition at line 1876 of file test_email.py.

01876 
01877     def test_lying_multipart(self):
01878         unless = self.assertTrue
01879         msg = self._msgobj('msg_41.txt')
01880         unless(hasattr(msg, 'defects'))
01881         self.assertEqual(len(msg.defects), 2)
01882         unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect))
01883         unless(isinstance(msg.defects[1],
01884                           errors.MultipartInvariantViolationDefect))

Here is the call graph for this function:

Definition at line 1885 of file test_email.py.

01885 
01886     def test_missing_start_boundary(self):
01887         outer = self._msgobj('msg_42.txt')
01888         # The message structure is:
01889         #
01890         # multipart/mixed
01891         #    text/plain
01892         #    message/rfc822
01893         #        multipart/mixed [*]
01894         #
01895         # [*] This message is missing its start boundary
01896         bad = outer.get_payload(1).get_payload(0)
01897         self.assertEqual(len(bad.defects), 1)
01898         self.assertTrue(isinstance(bad.defects[0],
01899                                    errors.StartBoundaryNotFoundDefect))

Here is the call graph for this function:

Definition at line 1818 of file test_email.py.

01818 
01819     def test_multipart_no_boundary(self):
01820         unless = self.assertTrue
01821         msg = self._msgobj('msg_25.txt')
01822         unless(isinstance(msg.get_payload(), str))
01823         self.assertEqual(len(msg.defects), 2)
01824         unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect))
01825         unless(isinstance(msg.defects[1],
01826                           errors.MultipartInvariantViolationDefect))

Here is the call graph for this function:

Definition at line 1865 of file test_email.py.

01865 
01866     def test_no_separating_blank_line(self):
01867         eq = self.ndiffAssertEqual
01868         msg = self._msgobj('msg_35.txt')
01869         eq(msg.as_string(), """\
01870 From: aperson@dom.ain
01871 To: bperson@dom.ain
01872 Subject: here's something interesting
01873 
01874 counter to RFC 2822, there's no separating newline here
01875 """)

Here is the call graph for this function:

Definition at line 1848 of file test_email.py.

01848 
01849     def test_no_start_boundary(self):
01850         eq = self.ndiffAssertEqual
01851         msg = self._msgobj('msg_31.txt')
01852         eq(msg.get_payload(), """\
01853 --BOUNDARY
01854 Content-Type: text/plain
01855 
01856 message 1
01857 
01858 --BOUNDARY
01859 Content-Type: text/plain
01860 
01861 message 2
01862 
01863 --BOUNDARY--
01864 """)

Here is the call graph for this function:

Definition at line 1801 of file test_email.py.

01801 
01802     def test_parse_missing_minor_type(self):
01803         eq = self.assertEqual
01804         msg = self._msgobj('msg_14.txt')
01805         eq(msg.get_content_type(), 'text/plain')
01806         eq(msg.get_content_maintype(), 'text')
01807         eq(msg.get_content_subtype(), 'plain')

Here is the call graph for this function:

Definition at line 1808 of file test_email.py.

01808 
01809     def test_same_boundary_inner_outer(self):
01810         unless = self.assertTrue
01811         msg = self._msgobj('msg_15.txt')
01812         # XXX We can probably eventually do better
01813         inner = msg.get_payload(0)
01814         unless(hasattr(inner, 'defects'))
01815         self.assertEqual(len(inner.defects), 1)
01816         unless(isinstance(inner.defects[0],
01817                           errors.StartBoundaryNotFoundDefect))

Here is the call graph for this function:


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