Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: Lib/test/test_email/test_email.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_dis.py ('k') | Lib/test/test_email/test_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2001-2010 Python Software Foundation 1 # Copyright (C) 2001-2010 Python Software Foundation
2 # Contact: email-sig@python.org 2 # Contact: email-sig@python.org
3 # email package unit tests 3 # email package unit tests
4 4
5 import os 5 import os
6 import re 6 import re
7 import sys 7 import sys
8 import time 8 import time
9 import base64 9 import base64
10 import difflib 10 import difflib
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 1801
1802 def test_multipart_no_boundary(self): 1802 def test_multipart_no_boundary(self):
1803 unless = self.assertTrue 1803 unless = self.assertTrue
1804 msg = self._msgobj('msg_25.txt') 1804 msg = self._msgobj('msg_25.txt')
1805 unless(isinstance(msg.get_payload(), str)) 1805 unless(isinstance(msg.get_payload(), str))
1806 self.assertEqual(len(self.get_defects(msg)), 2) 1806 self.assertEqual(len(self.get_defects(msg)), 2)
1807 unless(isinstance(self.get_defects(msg)[0], 1807 unless(isinstance(self.get_defects(msg)[0],
1808 errors.NoBoundaryInMultipartDefect)) 1808 errors.NoBoundaryInMultipartDefect))
1809 unless(isinstance(self.get_defects(msg)[1], 1809 unless(isinstance(self.get_defects(msg)[1],
1810 errors.MultipartInvariantViolationDefect)) 1810 errors.MultipartInvariantViolationDefect))
1811
1812 multipart_msg = textwrap.dedent("""\
1813 Date: Wed, 14 Nov 2007 12:56:23 GMT
1814 From: foo@bar.invalid
1815 To: foo@bar.invalid
1816 Subject: Content-Transfer-Encoding: base64 and multipart
1817 MIME-Version: 1.0
1818 Content-Type: multipart/mixed;
1819 boundary="===============3344438784458119861=="{}
1820
1821 --===============3344438784458119861==
1822 Content-Type: text/plain
1823
1824 Test message
1825
1826 --===============3344438784458119861==
1827 Content-Type: application/octet-stream
1828 Content-Transfer-Encoding: base64
1829
1830 YWJj
1831
1832 --===============3344438784458119861==--
1833 """)
1834
1835 def test_multipart_invalid_cte(self):
1836 msg = email.message_from_string(
1837 self.multipart_msg.format("\nContent-Transfer-Encoding: base64"),
1838 policy = self.policy)
1839 self.assertEqual(len(self.get_defects(msg)), 1)
1840 self.assertIsInstance(self.get_defects(msg)[0],
1841 errors.InvalidMultipartContentTransferEncodingDefect)
1842
1843 def test_multipart_no_cte_no_defect(self):
1844 msg = email.message_from_string(
1845 self.multipart_msg.format(''),
1846 policy = self.policy)
1847 self.assertEqual(len(self.get_defects(msg)), 0)
1848
1849 def test_multipart_valid_cte_no_defect(self):
1850 for cte in ('7bit', '8bit', 'BINary'):
1851 msg = email.message_from_string(
1852 self.multipart_msg.format(
1853 "\nContent-Transfer-Encoding: {}".format(cte)),
1854 policy = self.policy)
1855 self.assertEqual(len(self.get_defects(msg)), 0)
1856 1811
1857 def test_invalid_content_type(self): 1812 def test_invalid_content_type(self):
1858 eq = self.assertEqual 1813 eq = self.assertEqual
1859 neq = self.ndiffAssertEqual 1814 neq = self.ndiffAssertEqual
1860 msg = Message() 1815 msg = Message()
1861 # RFC 2045, $5.2 says invalid yields text/plain 1816 # RFC 2045, $5.2 says invalid yields text/plain
1862 msg['Content-Type'] = 'text' 1817 msg['Content-Type'] = 'text'
1863 eq(msg.get_content_maintype(), 'text') 1818 eq(msg.get_content_maintype(), 'text')
1864 eq(msg.get_content_subtype(), 'plain') 1819 eq(msg.get_content_subtype(), 'plain')
1865 eq(msg.get_content_type(), 'text/plain') 1820 eq(msg.get_content_type(), 'text/plain')
(...skipping 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after
4819 original, msg = self._msg_and_obj('msg_45.txt') 4774 original, msg = self._msg_and_obj('msg_45.txt')
4820 fp = StringIO() 4775 fp = StringIO()
4821 Generator(fp).flatten(msg) 4776 Generator(fp).flatten(msg)
4822 result = fp.getvalue() 4777 result = fp.getvalue()
4823 self._signed_parts_eq(original, result) 4778 self._signed_parts_eq(original, result)
4824 4779
4825 4780
4826 4781
4827 if __name__ == '__main__': 4782 if __name__ == '__main__':
4828 unittest.main() 4783 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_dis.py ('k') | Lib/test/test_email/test_utils.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+