Back to index

python3.2  3.2.2
Classes | Functions | Variables
email.test.test_email Namespace Reference

Classes

class  TestEmailBase
class  TestMessageAPI
class  TestEncoders
class  TestLongHeaders
class  TestFromMangling
class  TestMIMEAudio
class  TestMIMEImage
class  TestMIMEApplication
class  TestMIMEText
class  TestMultipart
class  TestNonConformant
class  TestRFC2047
class  TestMIMEMessage
class  TestIdempotent
class  TestMiscellaneous
class  TestIterators
class  TestParsers
class  Test8BitBytesHandling
class  BaseTestBytesGeneratorIdempotent
class  TestBytesGeneratorIdempotentNL
class  TestBytesGeneratorIdempotentCRLF
class  TestBase64
class  TestQuopri
class  TestCharset
class  TestHeader
class  TestRFC2231
class  TestSigned

Functions

def openfile
def test_unicode_charset_name
def test_utf8_shortest
 def test_unicode_error(self): raises = self.assertRaises raises(UnicodeError, Header, u'[P]', 'us-ascii') raises(UnicodeError, Header, '[P]', 'us-ascii') h = Header() raises(UnicodeError, h.append, u'[P]', 'us-ascii') raises(UnicodeError, h.append, '[P]', 'us-ascii') raises(UnicodeError, Header, u'', 'iso-8859-1')
def test_bad_8bit_header
def test_escaped_8bit_header
def test_header_handles_binary_unknown8bit
def test_make_header_handles_binary_unknown8bit
def test_modify_returned_list_does_not_change_header
def test_encoded_adjacent_nonencoded
def test_whitespace_eater
def test_broken_base64_header
def test_shift_jis_charset
def test_flatten_header_with_no_value
def test_encode_preserves_leading_ws_on_value
def _testclasses
def suite
def test_main

Variables

string NL = '\n'
string EMPTYSTRING = ''
string SPACE = ' '
tuple c = Charset('fake')

Function Documentation

Definition at line 4634 of file test_email.py.

04634 
04635 def _testclasses():
04636     mod = sys.modules[__name__]
04637     return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
04638 

Here is the call graph for this function:

Here is the caller graph for this function:

def email.test.test_email.openfile (   filename,
  args,
  kws 
)

Definition at line 49 of file test_email.py.

00049 
00050 def openfile(filename, *args, **kws):
00051     path = os.path.join(os.path.dirname(landmark), 'data', filename)
00052     return open(path, *args, **kws)
00053 
00054 
00055 
# Base test class

Here is the caller graph for this function:

Definition at line 4639 of file test_email.py.

04639 
04640 def suite():
04641     suite = unittest.TestSuite()
04642     for testclass in _testclasses():
04643         suite.addTest(unittest.makeSuite(testclass))
04644     return suite
04645 

Here is the call graph for this function:

Definition at line 4165 of file test_email.py.

04165 
04166     def test_bad_8bit_header(self):
04167         raises = self.assertRaises
04168         eq = self.assertEqual
04169         x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
04170         raises(UnicodeError, Header, x)
04171         h = Header()
04172         raises(UnicodeError, h.append, x)
04173         e = x.decode('utf-8', 'replace')
04174         eq(str(Header(x, errors='replace')), e)
04175         h.append(x, errors='replace')
04176         eq(str(h), e)

Here is the call graph for this function:

Definition at line 4225 of file test_email.py.

04225 
04226     def test_broken_base64_header(self):
04227         raises = self.assertRaises
04228         s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?='
04229         raises(errors.HeaderParseError, decode_header, s)

Here is the call graph for this function:

Definition at line 4241 of file test_email.py.

04241 
04242     def test_encode_preserves_leading_ws_on_value(self):
04243         msg = Message()
04244         msg['SomeHeader'] = '   value with leading ws'
04245         self.assertEqual(str(msg), "SomeHeader:    value with leading ws\n\n")
04246 
04247 
04248 
# Test RFC 2231 header parameters (en/de)coding

Definition at line 4206 of file test_email.py.

04206 
04207     def test_encoded_adjacent_nonencoded(self):
04208         eq = self.assertEqual
04209         h = Header()
04210         h.append('hello', 'iso-8859-1')
04211         h.append('world')
04212         s = h.encode()
04213         eq(s, '=?iso-8859-1?q?hello?= world')
04214         h = make_header(decode_header(s))
04215         eq(h.encode(), s)

Here is the call graph for this function:

Definition at line 4177 of file test_email.py.

04177 
04178     def test_escaped_8bit_header(self):
04179         x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
04180         e = x.decode('ascii', 'surrogateescape')
04181         h = Header(e, charset=email.charset.UNKNOWN8BIT)
04182         self.assertEqual(str(h),
04183                         'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
04184         self.assertEqual(email.header.decode_header(h), [(x, 'unknown-8bit')])

Here is the call graph for this function:

Definition at line 4234 of file test_email.py.

04234 
04235     def test_flatten_header_with_no_value(self):
04236         # Issue 11401 (regression from email 4.x)  Note that the space after
04237         # the header doesn't reflect the input, but this is also the way
04238         # email 4.x behaved.  At some point it would be nice to fix that.
04239         msg = email.message_from_string("EmptyHeader:")
04240         self.assertEqual(str(msg), "EmptyHeader: \n\n")

Here is the call graph for this function:

Definition at line 4185 of file test_email.py.

04185 
04186     def test_header_handles_binary_unknown8bit(self):
04187         x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
04188         h = Header(x, charset=email.charset.UNKNOWN8BIT)
04189         self.assertEqual(str(h),
04190                         'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
04191         self.assertEqual(email.header.decode_header(h), [(x, 'unknown-8bit')])

Here is the call graph for this function:

Definition at line 4646 of file test_email.py.

04646 
04647 def test_main():
04648     for testclass in _testclasses():
04649         run_unittest(testclass)
04650 
04651 

Here is the call graph for this function:

Definition at line 4192 of file test_email.py.

04192 
04193     def test_make_header_handles_binary_unknown8bit(self):
04194         x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
04195         h = Header(x, charset=email.charset.UNKNOWN8BIT)
04196         h2 = email.header.make_header(email.header.decode_header(h))
04197         self.assertEqual(str(h2),
04198                         'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
04199         self.assertEqual(email.header.decode_header(h2), [(x, 'unknown-8bit')])

Here is the call graph for this function:

Definition at line 4200 of file test_email.py.

04200 
04201     def test_modify_returned_list_does_not_change_header(self):
04202         h = Header('test')
04203         chunks = email.header.decode_header(h)
04204         chunks.append(('ascii', 'test2'))
04205         self.assertEqual(str(h), 'test')

Here is the call graph for this function:

Definition at line 4230 of file test_email.py.

04230 
04231     def test_shift_jis_charset(self):
04232         h = Header('文', charset='shift_jis')
04233         self.assertEqual(h.encode(), '=?iso-2022-jp?b?GyRCSjgbKEI=?=')

Definition at line 3886 of file test_email.py.

03886 
03887     def test_unicode_charset_name(self):
03888         charset = Charset('us-ascii')
03889         self.assertEqual(str(charset), 'us-ascii')
03890         self.assertRaises(errors.CharsetError, Charset, 'asc\xffii')
03891 
03892 
03893 
# Test multilingual MIME headers.

def test_unicode_error(self): raises = self.assertRaises raises(UnicodeError, Header, u'[P]', 'us-ascii') raises(UnicodeError, Header, '[P]', 'us-ascii') h = Header() raises(UnicodeError, h.append, u'[P]', 'us-ascii') raises(UnicodeError, h.append, '[P]', 'us-ascii') raises(UnicodeError, Header, u'', 'iso-8859-1')

Definition at line 4158 of file test_email.py.

04158 
04159     def test_utf8_shortest(self):
04160         eq = self.assertEqual
04161         h = Header('p\xf6stal', 'utf-8')
04162         eq(h.encode(), '=?utf-8?q?p=C3=B6stal?=')
04163         h = Header('\u83ca\u5730\u6642\u592b', 'utf-8')
04164         eq(h.encode(), '=?utf-8?b?6I+K5Zyw5pmC5aSr?=')

Definition at line 4216 of file test_email.py.

04216 
04217     def test_whitespace_eater(self):
04218         eq = self.assertEqual
04219         s = 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.'
04220         parts = decode_header(s)
04221         eq(parts, [(b'Subject:', None), (b'\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), (b'zz.', None)])
04222         hdr = make_header(parts)
04223         eq(hdr.encode(),
04224            'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.')

Here is the call graph for this function:


Variable Documentation

Definition at line 3883 of file test_email.py.

Definition at line 44 of file test_email.py.

Definition at line 43 of file test_email.py.

Definition at line 45 of file test_email.py.