
    <eK                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlZd dlZd dlmZ d dlmZmZmZ d d	lmZmZmZ d d
lmZ d dlm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z, d dl-m.Z. d dl/m0Z0 d dl1m2Z2m3Z3 d dlm4Z4 d dlm5Z5 d dlm6Z6 d dlm7Z7 d dlm8Z8 d dlm9Z9 d dl:m;Z; d dl<m=Z= d dl>m?Z?m@Z@ d dl1mAZAmBZB dZCd ZDd!ZE G d" d#e@          ZF G d$ d%ejG                  ZH G d& d'e@          ZI G d( d)ejG                  ZJ G d* d+ejG                  ZK G d, d-ejG                  ZL G d. d/ejG                  ZM G d0 d1ejG                  ZN G d2 d3e@          ZO G d4 d5e@          ZP G d6 d7e@          ZQ G d8 d9e@          ZR G d: d;e@          ZS G d< d=e@          ZT G d> d?e@          ZU G d@ dAe@          ZV G dB dCe@          ZW G dD dEe@          ZX G dF dGe@          ZY G dH dI          ZZ G dJ dKeZeT          Z[ G dL dMeZeT          Z\ G dN dOejG                  Z] G dP dQejG                  Z^ G dR dSejG                  Z_ G dT dUe@          Z` G dV dWe@          Za G dX dYe@          Zb G dZ d[e@          Zcedd\k    r eje                     dS dS )]    N)StringIOBytesIO)chainchoice)Thread)patch)Charset)	GeneratorDecodedGeneratorBytesGenerator)Headerdecode_headermake_header)HeaderRegistry)Message)MIMEApplication)	MIMEAudio)MIMEBase)	MIMEImage)MIMEMessage)MIMEMultipart)MIMENonMultipart)MIMEText)ParserHeaderParser)
base64mime)encoderserrors)	iterators)
quoprimime)utils)threading_helper)unlink)openfileTestEmailBase)
FeedParserBytesFeedParser
  c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFdE ZGdF ZHdG ZIdH ZJdI ZKdJ ZLdK ZMdL ZNdM ZOdN ZPdO ZQdP ZRdQ ZSdR ZTdS ZUdT ZVdU ZWdVS )WTestMessageAPIc                     | j         }|                     d          } ||                    d          g d            ||                    dd          d           d S )Nz
msg_20.txtcc)zccc@zzz.orgzddd@zzz.orgzeee@zzz.orgxxzn/a)assertEqual_msgobjget_allselfeqmsgs      1/usr/lib/python3.11/test/test_email/test_email.pytest_get_allzTestMessageAPI.test_get_all9   sf    ll<((
3;;tKKKLLL
3;;tU##U+++++    c                 :   | j         }t                      } ||                                d            t          d          }|                    |            ||d         d            ||                                d            ||d         d            ||                    d          d            ||d         d	            ||                                j        d           |                    d             ||                                d             ||d         d           t                      }d
|d<   d|d<   d|d<   |                    |            ||d         d
            ||d         d            ||d         d           d S )N
iso-8859-1mime-versionz1.0
text/plaincontent-typez text/plain; charset="iso-8859-1"charsetcontent-transfer-encodingquoted-printablez2.0zMIME-Versionztext/x-weirdContent-Typezquinted-puntableContent-Transfer-Encodingz"text/x-weird; charset="iso-8859-1")r2   r   get_charsetr
   set_charsetget_content_type	get_paraminput_charsetr6   r7   r8   rA   s       r9   test_getset_charsetz"TestMessageAPI.test_getset_charset?   s   ii
3??d###,''   
3~&&&
3!!<000
3~ BCCC
3==##\222
3*+-?@@@
3??*L999
3??d###
3~---ii#N,N+='(   
3~&&&
3~ DEEE
3*+-?@@@@@r;   c                     | j         }t                      }|                    d            ||                                j        d            ||d         d           d S )Nus-asciir@   text/plain; charset="us-ascii")r2   r   rG   rF   rJ   r5   s      r9   test_set_charset_from_stringz+TestMessageAPI.test_set_charset_from_stringY   sb    ii
###
3??*J777
3~ @AAAAAr;   c                     t                      }t          d          }|                    d|           |                     |                                j        d           d S )Nr=   zThis is a string payload)r   r
   set_payloadr2   rF   rJ   )r6   r8   rA   s      r9   test_set_payload_with_charsetz,TestMessageAPI.test_set_payload_with_charset`   sV    ii,''2G<<<**8,GGGGGr;   c                 L   d}t          d          }t                      }|                    ||           |                     |d         d           |                     |                    d          |           |                     |                                d           d S )N   АБВutf-8rB   base64Tdecodez	0JDQkdCS
)r
   r   rR   r2   get_payloadr6   datarA   r8   s       r9   +test_set_payload_with_8bit_data_and_charsetz:TestMessageAPI.test_set_payload_with_8bit_data_and_charsetf   s    *'""iig&&&898DDD55t<<<**L99999r;   c                 0   d}t          d          }d |_        t                      }|                    |                    d          |           |                     |d         d           |                     |                    d          |           d S NrU   rV   rB   8bitTrX   )r
   body_encodingr   rR   rY   r2   rZ   r[   s       r9   >test_set_payload_with_non_ascii_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_noneo   s    *'"" $iiG,,g666896BBB55t<<<<<r;   c                 
   d}t          d          }d |_        t                      }|                    ||           |                     |d         d           |                     |                    d          |           d S r_   )r
   ra   r   rR   r2   rZ   r[   s       r9   >test_set_payload_with_8bit_data_and_charset_body_encoding_nonezMTestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_nonex   s    *'"" $iig&&&896BBB55t<<<<<r;   c                     t                      }|                    g            |                     |                                g            d S Nr   rR   r2   rZ   r6   r8   s     r9   test_set_payload_to_listz'TestMessageAPI.test_set_payload_to_list   sC    ii**B/////r;   c                     t                      }d|d<   |                    d           t          t                                }|                     t          d|j        |           d S )Nmultipart/mixedrD   zstring payloadz[Aa]ttach.*non-multipart)r   rR   r   assertRaisesRegex	TypeErrorattach)r6   r8   sub_msgs      r9   "test_attach_when_payload_is_stringz1TestMessageAPI.test_attach_when_payload_is_string   sg    ii/N()))gii((y*D"z7	4 	4 	4 	4 	4r;   c                 `   | j         }|                     d          }|                                } ||g d           |                     d          }|                    d          } ||g d           |                     d          }|                                } ||g d           d S )Nz
msg_08.txt)NrN   r=   
iso-8859-2koi8-rz
msg_09.txtdingbat)rt   rN   r=   rt   rs   z
msg_12.txt)NrN   r=   Nrr   z
iso-8859-3rN   rs   )r2   r3   get_charsets)r6   r7   r8   charsetss       r9   test_get_charsetsz TestMessageAPI.test_get_charsets   s    ll<((##%%
8MMMNNNll<((##I..
8       	! 	! 	! ll<((##%%
8 : : : 	; 	; 	; 	; 	;r;   c                 &   | j         }|                     d          }d |                                D             } ||ddg           |                     d          }|                    d          } ||                                d           d S )N
msg_04.txtc                 6    g | ]}|                                 S  get_filename.0ps     r9   
<listcomp>z4TestMessageAPI.test_get_filename.<locals>.<listcomp>   "    AAA!Q^^%%AAAr;   msg.txt
msg_07.txt   dingusfish.gif)r2   r3   rZ   r}   )r6   r7   r8   	filenamessubparts        r9   test_get_filenamez TestMessageAPI.test_get_filename   s    ll<((AAs/@/@AAA	
9y),---ll<((//!$$
7!!#344444r;   c                     | j         }|                     d          }d |                                D             } ||ddg           d S )Nz
msg_44.txtc                 6    g | ]}|                                 S r{   r|   r~   s     r9   r   zHTestMessageAPI.test_get_filename_with_name_parameter.<locals>.<listcomp>   r   r;   r   r2   r3   rZ   )r6   r7   r8   r   s       r9   %test_get_filename_with_name_parameterz4TestMessageAPI.test_get_filename_with_name_parameter   sU    ll<((AAs/@/@AAA	
9y),-----r;   c                 z    | j         }|                     d          } ||                                d           d S )Nr   BOUNDARY)r2   r3   get_boundaryr5   s      r9   test_get_boundaryz TestMessageAPI.test_get_boundary   s?    ll<((
3z*****r;   c                 N   | j         }|                     d          }|                    d           |                                d         \  }} ||                                d            ||d           |                     d          }|                    d           |                                d         \  }} ||                                d            ||d           |                     d          }|                     t          j        |j        d           d S )	N
msg_01.txtr      r@   z3text/plain; charset="us-ascii"; boundary="BOUNDARY"ry   z$multipart/mixed; boundary="BOUNDARY"
msg_03.txt)r2   r3   set_boundaryitemslowerassertRaisesr    HeaderParseError)r6   r7   r8   headervalues        r9   test_set_boundaryz TestMessageAPI.test_set_boundary   s    ll<(($$$		A
6<<>>>***
5GHHH ll<(($$$		A
6<<>>>***
58999ll<((&1*J	8 	8 	8 	8 	8r;   c                 ,   t          d          }|                     |                                d         d         d           |                                 |                     |                                d         d         d d         d           d S )Nz	form-datar   r   zmultipart/form-data!   z!multipart/form-data; boundary="==)r   r2   r   	as_stringrh   s     r9   test_make_boundaryz!TestMessageAPI.test_make_boundary   s    K(( 	Q*,ABBBQ*3B3/;	= 	= 	= 	= 	=r;   c                    t          dd          5 }|                                }d d d            n# 1 swxY w Y   t                      }|                    |          }t	                      }t          |dd          }|                    |d           |                     |                                |           d S )N
msg_46.txtrV   encodingTr   F)	r&   readr   parsestrr   r   flattenr2   getvaluer6   fpmsgdataparserr8   outgens          r9   test_message_rfc822_onlyz'TestMessageAPI.test_message_rfc822_only   s     lW555 	 ggiiG	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 oog&&jjT1%%C11111   377c                    t          dd          5 }|                                                    d          }d d d            n# 1 swxY w Y   t          j                                        }|                    |          }t                      }t          j        	                    |          }|
                    |           |                     |                                |           d S )Nr   rV   r   ascii)r&   r   encodeemailr   BytesHeaderParser
parsebytesr   	generatorr   r   r2   r   r   s          r9   test_byte_message_rfc822_onlyz,TestMessageAPI.test_byte_message_rfc822_only   s    lW555 	0ggii&&w//G	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0//11((iio,,S11C11111s   (AA
A
c                 |   | j         }|                     d          } ||                    d          d             ||                    d                              d          d            ||                    d                              d          d            ||                    d                              d          d	            ||                    d
                              d          d            ||                    d                              d          d           d S )Nz
msg_10.txtTrX   r   s    This is a 7bit encoded message.
r   s-   This is a Quoted Printable encoded message!
   s!   This is a Base64 encoded message.   s"   This is a Base64 encoded message.
r   s/   This has no Content-Transfer-Encoding: header.
r   r5   s      r9   test_get_decoded_payloadz'TestMessageAPI.test_get_decoded_payload   sc   ll<((
3??$?''...
3??1)))66/	1 	1 	1 	3??1)))66?	A 	A 	A 	3??1)))66/	1 	1 	1 	3??1)))661	3 	3 	3 	3??1)))66>	@ 	@ 	@ 	@ 	@r;   c                    | j         }t                      }|                    d           dD ]'}||d<    ||                    d          d           (|                    d            ||                    d          d           d S )	Nz$begin 666 -
+:&5L;&\@=V]R;&0 
 
end
z
x-uuencodeuuencodeuuezx-uuerB   TrX      hello worldfoos   foo)r2   r   rR   rZ   )r6   r7   r8   ctes       r9   test_get_decoded_uu_payloadz*TestMessageAPI.test_get_decoded_uu_payload  s    iiCDDD= 	= 	=C/2C+,Bsd++^<<<<
3??$?''00000r;   c                 d    t                      }|                     t          |j        d           d S )Nr   )r   r   rm   rZ   rh   s     r9   *test_get_payload_n_raises_on_non_multipartz9TestMessageAPI.test_get_payload_n_raises_on_non_multipart  s+    ii)S_a88888r;   c                 X   | j         }|                     d          }t          dd          5 }|                                }d d d            n# 1 swxY w Y   t	                      }t          |          }|                    |            ||                                |           d S )Nr   z
msg_17.txtrV   r   )r2   r3   r&   r   r   r   r   r   )r6   r7   r8   r   textsgs          r9   test_decoded_generatorz%TestMessageAPI.test_decoded_generator  s    ll<((lW555 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	JJQ			#
1::<<s   AAAc                 >   t                      }d|d<   d|d<   |                     d|           |                     d|           |                     d|           |                     d|           |                     d|           |                     d|           d S )	NMeFromYoutofromFROMToTO)r   assertInrh   s     r9   test__contains__zTestMessageAPI.test__contains__  s    iiFD	fc"""fc"""fc"""dC   dC   dC     r;   c                    |                      d          }t          dd          5 }|                                }d d d            n# 1 swxY w Y   |                     |t	          |                     |                    d          }|                    d          }|                     |d                             d                     |                     |t          
                    |d	d                               d S )
Nr   rV   r   Tunixfromr*   r   zFrom r   )r3   r&   r   r2   strr   split
assertTrue
startswithNLjoin)r6   r8   r   r   fullreprliness         r9   test_as_stringzTestMessageAPI.test_as_string*  s   ll<((lW555 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s3xx(((==$=//t$$a++G44555rwwuQRRy1122222s   AAAc                 J   |                      d          }|j                            d          }|                    |          }t	                      }t          ||          }|                    |           |                     ||                                           d S Nr   
lineseppolicy)	r3   r   cloner   r   r   r   r2   r   r6   r8   	newpolicyr   r   r   s         r9   test_as_string_policyz$TestMessageAPI.test_as_string_policy4  s    ll<((J$$V$44	==	=22JJa	***			#1::<<00000r;   c                     t          j        d          }|                    d          }t          j        d          }t          j        |          }|                     |                                |           d S )Nu               MIME-Version: 1.0
            Content-type: text/plain; charset="iso-8859-1"

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            Föö bär
            r=   a%              MIME-Version: 1.0
            Content-type: text/plain; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            Test if non-ascii messages with no Content-Transfer-Encoding set
            can be as_string'd:
            F=F6=F6 b=E4r
            )textwrapdedentr   r   message_from_bytesr2   r   r6   msourceexpectedr8   s        r9   #test_nonascii_as_string_without_ctez2TestMessageAPI.test_nonascii_as_string_without_cte=  sw    O    ,''? $   &v..(33333r;   c                     t          j        d          }|                    d          }|                    dd          }t	          j        |          }|                     |                                |           d S )Nu               MIME-Version: 1.0

            Test if non-ascii messages with no Content-Type nor
            Content-Transfer-Encoding set can be as_string'd:
            Föö bär
            r=   r   replace)r   r   r   rY   r   r   r2   r   r   s        r9   4test_nonascii_as_string_without_content_type_and_ctezCTestMessageAPI.test_nonascii_as_string_without_content_type_and_cteS  sr    O    ,''==)44&v..(33333r;   c                 *   |                      d          }t          dd          5 }|                                                    d          }d d d            n# 1 swxY w Y   |                     |t          |                     |                    d          }|                    d          }|                     |d         	                    d	                     |                     |d
                    |d
d                               d S )Nr   rV   r   r   Tr      
r   s   From r   )r3   r&   r   r   r2   bytesas_bytesr   r   r   r   )r6   r8   r   r\   r   r   s         r9   test_as_byteszTestMessageAPI.test_as_bytes`  s'   ll<((lW555 	-7799##G,,D	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-uSzz***<<<..u%%a++H55666uzz%)4455555s   (AA"Ac                 J   |                      d          }|j                            d          }|                    |          }t	                      }t          ||          }|                    |           |                     ||                                           d S r   )	r3   r   r   r   r   r   r   r2   r   r   s         r9   test_as_bytes_policyz#TestMessageAPI.test_as_bytes_policyj  s    ll<((J$$V$44	<<y<11II1I...			#1::<<00000r;   c                     t          j        d          }|                     |                    d          d           d S )NzContent-Type: blarg; baz; boo
bazr+   r   message_from_stringr2   rI   rh   s     r9   test_bad_paramzTestMessageAPI.test_bad_paramt  s;    '(IJJu--r22222r;   c                 ~    t          j        d          }|                     |                                d            d S Nz
From: foo
r   r  r2   r}   rh   s     r9   test_missing_filenamez$TestMessageAPI.test_missing_filenamex  :    '66))++T22222r;   c                 ~    t          j        d          }|                     |                                d           d S )Nz%Content-Disposition: blarg; filename
r+   r	  rh   s     r9   test_bogus_filenamez"TestMessageAPI.test_bogus_filename|  s?    '02 2))++R00000r;   c                 ~    t          j        d          }|                     |                                d            d S r  r   r  r2   r   rh   s     r9   test_missing_boundaryz$TestMessageAPI.test_missing_boundary  r  r;   c                    | j         }t          j        d          } ||                    d          g d           t          j        d          } ||                    d          g d            ||                                d            t          j        d          } ||                    d          g d           d S )N&X-Header: foo=one; bar=two; baz=three
x-headerr   ))r   one)bartwor  threez X-Header: foo; bar=one; baz=two
))r   r+   )r  r  )r  r  "X-Header: foo; bar="one"; baz=two
)r2   r   r  
get_paramsr5   s      r9   test_get_paramszTestMessageAPI.test_get_params  s    '57 7
3>>>,,===	? 	? 	?'/1 1
3>>>,,888	: 	: 	:
3>>T"""'13 3
3>>>,,888	: 	: 	: 	: 	:r;   c                 ~    t                      }d|d<   |                     |                    d          d           d S )Nz>Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"rD   boundaryCPIMSSMTPC06p5f3tG)r   r2   rI   rh   s     r9   test_get_param_liberalz%TestMessageAPI.test_get_param_liberal  s>    ii^Nz224HIIIIIr;   c                    | j         }t          j        d          } ||                    dd          d            ||                    dd          d             ||                    d          d            t          j        d          } ||                    dd          d	            ||                    dd          d
            ||                    dd          d           d S )Nr  r  r  r  r  quuzr  r   r+   r  r  r2   r   r  rI   r5   s      r9   test_get_paramzTestMessageAPI.test_get_param  s   '57 7
3==z=22E:::
3==
=33T:::
3==  $''''13 3
3==z=22B777
3==z=22E:::
3==z=22E:::::r;   c                     |                      d          }|                     |                    d                              d          d           d S )Nz
msg_22.txtr   namez
wibble.JPG)r3   r2   rZ   rI   rh   s     r9   'test_get_param_funky_continuation_linesz6TestMessageAPI.test_get_param_funky_continuation_lines  sI    ll<((++55f==|LLLLLr;   c                     t          j        d          }|                     |                    d          d           |                     |                    dd          d           d S )Nz4Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill"
r&  zJim&amp;&amp;JillFunquotez"Jim&amp;&amp;Jill"r  rh   s     r9   #test_get_param_with_semis_in_quotesz2TestMessageAPI.test_get_param_with_semis_in_quotes  ss    'CE Ev..0CDDDvu==.	0 	0 	0 	0 	0r;   c                     t          j        d          }|                     |                    d          d           t          j        d          }|                     |                    d          d           d S )Nz5Content-Type: foo; bar*0="baz\"foobar"; bar*1="\"baz"r  zbaz"foobar"bazr  rh   s     r9   test_get_param_with_quotesz)TestMessageAPI.test_get_param_with_quotes  s|    'EG Gu--/?@@@'KM Mu--/?@@@@@r;   c                     t          j        d          }|                     d|           |                     d|           |                     d|           |                     d|           d S )NzHeader: existsr   r   HEADERheaderx)r   r  r   assertNotInrh   s     r9   test_field_containmentz%TestMessageAPI.test_field_containment  sk    '(899h$$$h$$$h$$$C(((((r;   c                 <   | j         }t                      }|                    dd            ||                    d          d           |                    dd            ||                    d          d            ||                    dd          d            ||                                g d            ||                    d          g d	           |                    dd
d            ||                    dd          d
           d S )NrA   iso-2022-jp
importance
high valueFr)  "high value")r?   r+   )rA   r4  )r5  r6  )r8  )rA   z"iso-2022-jp")r5  r7  ziso-9999-xxzX-Jimmyr  )r2   r   	set_paramrI   r  r5   s      r9   test_set_paramzTestMessageAPI.test_set_param  sE   iii///
3==##]333lL111
3==&&555
3==u=55~FFF
3>> < < < 	= 	= 	= 	3>>%>(( +G +G +G 	H 	H 	H 	iyAAA
3==9=55}EEEEEr;   c                    | j         }|                     d          } ||                                g d           |                    d          }|                    d            ||                                ddg           |                    d|            ||                                ddd|fg           d S )N
msg_05.txt)multipart/reportr+   )report-typedelivery-statusr  %D1690A7AC1.996856090/mail.example.comr?  r=  rA  )r2   r3   r  rI   	del_paramr9  )r6   r7   r8   old_vals       r9   test_del_paramzTestMessageAPI.test_del_param  s    ll<((
3>>C C C	D 	D 	D --..m$$$
3>>$AC	D 	D 	D 	mW---
3>>$AG$&	' 	' 	' 	' 	'r;   c                     t                      }|                    ddd           |                    dd           |                     |d         d           d S )NContent-Disposition
attachmentbud.giffilenamerK  content-dispositionr   
add_headerrC  r2   rh   s     r9   test_del_param_on_other_headerz-TestMessageAPI.test_del_param_on_other_header  s[    ii,lYOOOj"788823\BBBBBr;   c                 N    t                      }|                    dd           d S )NrK  rL  )r   rC  rh   s     r9   $test_del_param_on_nonexistent_headerz3TestMessageAPI.test_del_param_on_nonexistent_header  s&    iij"788888r;   c                     t                      }|                    ddd           |d         }|                    dd           |                     |d         |           d S )NrD   r?   rV   rA   foobarr  rM  )r6   r8   existing_headers      r9   test_del_nonexistent_paramz)TestMessageAPI.test_del_nonexistent_param  sd    ii~|WEEEn-h~666^,o>>>>>r;   c                 ^   | j         }t                      }|                     t          |j        d           |                    d            ||d         d           |                    dd            ||d         d           |                    d            ||d         d           d S )	Nr   r?   r@   rA   rN   rO   z	text/htmlztext/html; charset="us-ascii")r2   r   r   
ValueErrorset_typer9  r5   s      r9   test_set_typezTestMessageAPI.test_set_type  s    ii*clF;;;\"""
3~---i,,,
3~ @AAA[!!!
3~ ?@@@@@r;   c                     t                      }d|d<   |                    dd           |                     |d         d           d S )Nr?   zX-Content-Typeapplication/octet-streamzx-content-type)r   rY  r2   rh   s     r9   test_set_type_on_other_headerz,TestMessageAPI.test_set_type_on_other_header  sO    ii ,/1ABBB-.0JKKKKKr;   c                 r    t                      }|                     |                                d           d S )Nr?   )r   r2   rH   rh   s     r9   test_get_content_type_missingz,TestMessageAPI.test_get_content_type_missing  s3    ii--//>>>>>r;   c                     t                      }|                    d           |                     |                                d           d S )Nmessage/rfc822)r   set_default_typer2   rH   rh   s     r9   /test_get_content_type_missing_with_default_typez>TestMessageAPI.test_get_content_type_missing_with_default_type  sI    ii-...--//1ABBBBBr;   c                     |                      d          }|                     |                    d                                          d           d S )N
msg_30.txtr   ra  r3   r2   rZ   rH   rh   s     r9   +test_get_content_type_from_message_implicitz:TestMessageAPI.test_get_content_type_from_message_implicit  R    ll<((++<<>>)	+ 	+ 	+ 	+ 	+r;   c                     |                      d          }|                     |                    d                                          d           d S )N
msg_28.txtr   ra  rf  rh   s     r9   +test_get_content_type_from_message_explicitz:TestMessageAPI.test_get_content_type_from_message_explicit  rh  r;   c                     |                      d          }|                     |                                d           d S )Nr   r?   r3   r2   rH   rh   s     r9   6test_get_content_type_from_message_text_plain_implicitzETestMessageAPI.test_get_content_type_from_message_text_plain_implicit!  ;    ll<((--//>>>>>r;   c                     |                      d          }|                     |                                d           d S )Nr   r?   rm  rh   s     r9   6test_get_content_type_from_message_text_plain_explicitzETestMessageAPI.test_get_content_type_from_message_text_plain_explicit%  ro  r;   c                 r    t                      }|                     |                                d           d S )Nr   r   r2   get_content_maintyperh   s     r9   !test_get_content_maintype_missingz0TestMessageAPI.test_get_content_maintype_missing)  s3    ii1133V<<<<<r;   c                     t                      }|                    d           |                     |                                d           d S )Nra  message)r   rb  r2   rt  rh   s     r9   3test_get_content_maintype_missing_with_default_typezBTestMessageAPI.test_get_content_maintype_missing_with_default_type-  sH    ii-...1133Y?????r;   c                     |                      d          }|                     |                    d                                          d           d S )Nre  r   rw  r3   r2   rZ   rt  rh   s     r9   /test_get_content_maintype_from_message_implicitz>TestMessageAPI.test_get_content_maintype_from_message_implicit2  G    ll<((++@@BBINNNNNr;   c                     |                      d          }|                     |                    d                                          d           d S )Nrj  r   rw  rz  rh   s     r9   /test_get_content_maintype_from_message_explicitz>TestMessageAPI.test_get_content_maintype_from_message_explicit6  r|  r;   c                     |                      d          }|                     |                                d           d S )Nr   r   r3   r2   rt  rh   s     r9   :test_get_content_maintype_from_message_text_plain_implicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_implicit:  ;    ll<((1133V<<<<<r;   c                     |                      d          }|                     |                                d           d S )Nr   r   r  rh   s     r9   :test_get_content_maintype_from_message_text_plain_explicitzITestMessageAPI.test_get_content_maintype_from_message_text_plain_explicit>  r  r;   c                 r    t                      }|                     |                                d           d S )Nplainr   r2   get_content_subtyperh   s     r9    test_get_content_subtype_missingz/TestMessageAPI.test_get_content_subtype_missingB  s3    ii0022G<<<<<r;   c                     t                      }|                    d           |                     |                                d           d S )Nra  rfc822)r   rb  r2   r  rh   s     r9   2test_get_content_subtype_missing_with_default_typezATestMessageAPI.test_get_content_subtype_missing_with_default_typeF  sH    ii-...0022H=====r;   c                     |                      d          }|                     |                    d                                          d           d S )Nre  r   r  r3   r2   rZ   r  rh   s     r9   .test_get_content_subtype_from_message_implicitz=TestMessageAPI.test_get_content_subtype_from_message_implicitK  G    ll<((++??AA8LLLLLr;   c                     |                      d          }|                     |                    d                                          d           d S )Nrj  r   r  r  rh   s     r9   .test_get_content_subtype_from_message_explicitz=TestMessageAPI.test_get_content_subtype_from_message_explicitO  r  r;   c                     |                      d          }|                     |                                d           d S )Nr   r  r3   r2   r  rh   s     r9   9test_get_content_subtype_from_message_text_plain_implicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_implicitS  ;    ll<((0022G<<<<<r;   c                     |                      d          }|                     |                                d           d S )Nr   r  r  rh   s     r9   9test_get_content_subtype_from_message_text_plain_explicitzHTestMessageAPI.test_get_content_subtype_from_message_text_plain_explicitW  r  r;   c                 |    t                      }d|d<   |                     |                                d           d S )Nno-slash-in-this-stringrD   r   rs  rh   s     r9   test_get_content_maintype_errorz.TestMessageAPI.test_get_content_maintype_error[  s=    ii7N1133V<<<<<r;   c                 |    t                      }d|d<   |                     |                                d           d S )Nr  rD   r  r  rh   s     r9   test_get_content_subtype_errorz-TestMessageAPI.test_get_content_subtype_error`  s=    ii7N0022G<<<<<r;   c                    | j         }t                      }|                    dd           |                    dd           |                    dd            ||                                g d            ||                                g d           |                    dd	            ||                                g d            ||                                g d
           |                    dd           |                    dd            ||                                g d            ||                                g d           |                     t          |j        dd           d S )NFirstOneSecondTwoThirdThree)r  r  r  )r  r  r  Twenty)r  r  r  ElevenOne Hundred)r  r  r  r  )r  r  r  r  FourthMissing)r2   r   rN  keysvaluesreplace_headerr   KeyErrorr5   s      r9   test_replace_headerz"TestMessageAPI.test_replace_headere  sx   iiw&&&x'''w(((
388::333444
3::<<0001118X...
388::333444
3::<<333444w)))7M222
388::<<<===
3::<<EEEFFF(C$6)LLLLLr;   c                    t                      }|                     |                                           |                    ddd           |                     |                                d           |                    dd           |                     |                                d           |                    dd           |                     |                                d           d S )NrG  rH  z
random.avirJ  inlineInlinE)r   assertIsNoneget_content_dispositionrN  r2   r  rh   s     r9   test_get_content_dispositionz+TestMessageAPI.test_get_content_dispositionv  s    ii#5577888,l , 	 	. 	. 	.4466EEE0(;;;4466AAA0(;;;4466AAAAAr;   c                    d}t                      }d|d<   d|d<   |                    |           |                     |                    d          d           |                     |j        d	         t          j                   d S )
NzAwDp0P7//y6LwKEAcPa/6Q=9zaudio/x-midir@   rW   rB   TrX   s    . pr   )r   rR   r2   rZ   assertIsInstancedefectsr    InvalidBase64CharactersDefectr6   xr8   s      r9   test_broken_base64_payloadz)TestMessageAPI.test_broken_base64_payload  s    &ii,N+3'(557	9 	9 	9 	ck!n$B	D 	D 	D 	D 	Dr;   c                     d}t                      }d|d<   d|d<   |                    |           |                     |                    d          t	          |d                     d S )	Nu   this is a bröken thing to dor?   r@   r`   rB   TrX   zraw-unicode-escape)r   rR   r2   rZ   r   r  s      r9   test_broken_unicode_payloadz*TestMessageAPI.test_broken_unicode_payload  sy     .ii*N+1'(55q"677	9 	9 	9 	9 	9r;   c                     d                     d          }t                      }d|d<   d|d<   ||_        |                     |                    d          |           d S )	Nu#   this is a quéstionable thing to dorV   text/plain; charset="utf-8"r@   r`   rB   TrX   )r   r   _payloadr2   rZ   r  s      r9   test_questionable_bytes_payloadz.TestMessageAPI.test_questionable_bytes_payload  sf     288AAii;N+1'(55q99999r;   c                     t                      }|                    ddd           |                     d|d                    d S )NrG  rH  rI  rJ  zattachment; filename="bud.gif"r   rN  r2   rh   s     r9   test_ascii_add_headerz$TestMessageAPI.test_ascii_add_header  s\    ii,l ) 	 	+ 	+ 	+9%&	( 	( 	( 	( 	(r;   c                     t                      }|                    ddd           |                     d|d                    d S )NrG  rH     Fußballer.pptrJ  z/attachment; filename*=utf-8''Fu%C3%9Fballer.pptr  rh   s     r9   test_noascii_add_headerz&TestMessageAPI.test_noascii_add_header  s\    ii,l% 	 	' 	' 	'?%&	( 	( 	( 	( 	(r;   c                     t                      }|                    ddd           |                     d|d                    d S )NrG  rH  )r=   r+   r  rJ  z1attachment; filename*=iso-8859-1''Fu%DFballer.pptr  rh   s     r9   #test_nonascii_add_header_via_triplez2TestMessageAPI.test_nonascii_add_header_via_triple  s\    ii,l9 	 	; 	; 	;A%&	( 	( 	( 	( 	(r;   c                     t                      }|                    ddd           |                     d|d                    d S )NrG  rH  zwindows [filename].pptrJ  z-attachment; filename="windows [filename].ppt"r  rh   s     r9   #test_ascii_add_header_with_tspecialz2TestMessageAPI.test_ascii_add_header_with_tspecial  s\    ii,l- 	 	/ 	/ 	/;%&	( 	( 	( 	( 	(r;   c                     t                      }|                    ddd           |                     d|d                    d S )NrG  rH  u   Fußballer [filename].pptrJ  z@attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.pptr  rh   s     r9   &test_nonascii_add_header_with_tspecialz5TestMessageAPI.test_nonascii_add_header_with_tspecial  s\    ii,l0 	 	2 	2 	2N%&	( 	( 	( 	( 	(r;   c                     dD ]`}t                      }d|z  |d<   d|d<   |                    d           |                     |                    d          d	d
|z             ad S )Nlatin-1r   text/plain; charset=%sr@   rC   rB   s   foo=e6=96=87barTrX   	   foo文bar1get_payload returns wrong result with charset %s.rg   r6   rA   r8   s      r9   test_binary_quopri_payloadz)TestMessageAPI.test_binary_quopri_payload  s    + 	O 	OG))C":W"DC/AC+,OO.///t,,%CgMO O O O	O 	Or;   c                     dD ]`}t                      }d|z  |d<   d|d<   |                    d           |                     |                    d          d	d
|z             ad S )Nr  r  r@   rW   rB   s   Zm9v5paHYmFyTrX   r  r  rg   r  s      r9   test_binary_base64_payloadz)TestMessageAPI.test_binary_base64_payload  s    + 	O 	OG))C":W"DC/7C+,OOO,,,t,,%CgMO O O O	O 	Or;   c           
         dD ]}dD ]~}t                      }d|z  |d<   ||d<   |                    d           |                     |                    d          d	t	          d
                              ||                     d S )Nr  r   r  r@   rB   s    begin 666 -
)9F]OYI:'8F%R
 
end
TrX   r  )z!get_payload returns wrong result z"with charset {0} and encoding {1}.)r   rR   r2   rZ   r   format)r6   rA   r   r8   s       r9   test_binary_uuencode_payloadz+TestMessageAPI.test_binary_uuencode_payload  s    + 	3 	3GF 
3 
3ii&>&HN#3;/0 GHHH  OO4O00) ? @ @w113 3 3 3
3	3 	3r;   c                     t                      }|                    ddd            |                     d|d                    d S )NrG  r  )foo_barzinline; foo-barr  rh   s     r9   $test_add_header_with_name_only_paramz3TestMessageAPI.test_add_header_with_name_only_param  sG    ii,hEEE*C0E,FGGGGGr;   c                     t                      }|                    dd            |                     d|d                    d S )NzX-Statusr+   r  rh   s     r9   test_add_header_with_no_valuez,TestMessageAPI.test_add_header_with_no_value  s?    iiz4(((S_-----r;   c                     t                      }t          d          |d<   |                     t          j        |j                   d S Nzdummy
X-Injected-Header: testDummy)r   r   r   r    r   r   rh   s     r9   (test_embedded_header_via_Header_rejectedz7TestMessageAPI.test_embedded_header_via_Header_rejected  s>    ii>??G&13=AAAAAr;   c                 v    t                      }d|d<   |                     t          j        |j                   d S r  )r   r   r    r   r   rh   s     r9   (test_embedded_header_via_string_rejectedz7TestMessageAPI.test_embedded_header_via_string_rejected   s5    ii7G&13=AAAAAr;   c                     t          d          }d|d<   |                     t          |          t          j        d                     d S )Nzabc
u   É testSubjectz            Content-Type: text/plain; charset="us-ascii"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 7bit
            Subject: =?utf-8?q?=C3=89_test?=

            abc
            r   r2   r   r   r   r6   r   s     r9   -test_unicode_header_defaults_to_utf8_encodingz<TestMessageAPI.test_unicode_header_defaults_to_utf8_encoding  sU    W )Q 1 ! ! 	 	 	 	 	r;   c                     t          d          }|                     t          |          t          j        d                     d S )Nu   É testabc
z            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: base64

            w4kgdGVzdGFiYwo=
            r  r  s     r9   +test_unicode_body_defaults_to_utf8_encodingz:TestMessageAPI.test_unicode_body_defaults_to_utf8_encoding  sL    ^$$Q 1 ! ! 	 	 	 	 	r;   N)X__name__
__module____qualname__r:   rL   rP   rS   r]   rb   rd   ri   rp   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r   r$  r'  r+  r-  r2  r:  rE  rO  rQ  rV  rZ  r]  r_  rc  rg  rk  rn  rq  ru  rx  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r{   r;   r9   r.   r.   8   sZ       , , ,A A A4B B BH H H: : := = == = =0 0 0
4 4 4; ; ;"	5 	5 	5. . .+ + +8 8 8,= = =
2 
2 
2	2 	2 	2@ @ @,	1 	1 	19 9 9  
! 
! 
!3 3 31 1 14 4 4,4 4 46 6 61 1 13 3 33 3 31 1 1
3 3 3: : :"J J J
; ; ;$M M M
0 0 0A A A) ) )F F F"' ' '"C C C9 9 9
? ? ?	A 	A 	AL L L? ? ?C C C
+ + +
+ + +
? ? ?? ? ?= = =@ @ @
O O OO O O= = == = == = => > >
M M MM M M= = == = == = =
= = =
M M M"	B 	B 	B
D 
D 
D	9 	9 	9: : :( ( (( ( (( ( (( ( (( ( (	O 	O 	O	O 	O 	O3 3 3H H H
. . .B B B
B B B
  	 	 	 	 	r;   r.   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestEncodersc                 r   t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          j        j                            |          }|                                }|                    d          }|                     t          d |D                       d           d S )N
python.gifrbr*   c                 ,    g | ]}t          |          S r{   )lenr   r  s     r9   r   z;TestEncoders.test_EncodersEncode_base64.<locals>.<listcomp>(  s    !:!:!:a3q66!:!:!:r;   L   )
r&   r   r   mimeimager   rZ   r   assertLessEqualmax)r6   r   bindatamimedbase64edr   s         r9   test_EncodersEncode_base64z'TestEncoders.test_EncodersEncode_base64!  s    lD)) 	 RggiiG	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 
 **733$$&&t$$S!:!:5!:!:!:;;R@@@@@   266c                 ~    | j         }t                      }|                    d            ||d         d           d S )NrN   rB   7bit)r2   r   rG   r5   s      r9   test_encode_empty_payloadz&TestEncoders.test_encode_empty_payload*  sC    ii
###
3*+V44444r;   c                     | j         }t          d          } ||d         d           t          d          } ||d         d           t          dd          } ||d         d           d S )	Nhello worldrB   r  u   hello ø worldrW   r=   _charsetrC   )r2   r   r5   s      r9   test_default_ctezTestEncoders.test_default_cte0  s    }%%
3*+V444)**
3*+X666)LAAA
3*+-?@@@@@r;   c                     | j         }t          dd          } ||d         d            ||                                t          j        d                     d S )Nu   文
euc-jpr  rB   r  z            MIME-Version: 1.0
            Content-Type: text/plain; charset="iso-2022-jp"
            Content-Transfer-Encoding: 7bit

            $BJ8(B
            )r2   r   r   r   r   r5   s      r9   test_encode7or8bitzTestEncoders.test_encode7or8bit<  sq     w222
3*+V444
3==??HO -   	 	 	 	 	r;   c                     t          ddd          }|                     t          |          t          j        d                     d S )Nu   áö
r   z
ISO-8859-1z            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-1"
            Content-Transfer-Encoding: quoted-printable

            =E1=F6
            r  rh   s     r9   test_qp_encode_latin1z"TestEncoders.test_qp_encode_latin1K  sP    |V\::S8? 4 $ $ 	 	 	 	 	r;   c                     t          ddd          }|                     t          |          t          j        d                     d S )Nu   ż
r   z
ISO-8859-2z            MIME-Version: 1.0
            Content-Type: text/text; charset="iso-8859-2"
            Content-Transfer-Encoding: quoted-printable

            =BF
            r  rh   s     r9   test_qp_encode_non_latin1z&TestEncoders.test_qp_encode_non_latin1U  sP    z6<88S8? 4 $ $ 	 	 	 	 	r;   N)	r  r  r  r   r  r	  r  r  r  r{   r;   r9   r  r    st        A A A5 5 5
A 
A 
A    	 	 	 	 	r;   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*dS ))TestLongHeadersNc                     | j         }t          j        d          }t                      }t	          |          }|                    |            ||                                d           d S )NzSubject: bug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text

test
)ndiffAssertEqualr   r  r   r   r   r   r6   r7   r8   sfpr   s        r9   test_split_long_continuationz,TestLongHeaders.test_split_long_continuationf  ss    "' )   jjcNN			#
3<<>>  	 	 	 	 	r;   c                     | j         }d}t          |d          } ||                                d           t          |                    dd                    } ||                                d           d S )Nzbug demonstration
	12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
	more text	continuation_wsr,   zbug demonstration
 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
 more text)r  r   r   r   r6   r7   hstrhs       r9   ,test_another_long_almost_unsplittable_headerz<TestLongHeaders.test_another_long_almost_unsplittable_headerz  s    " 4...
188::  	 	 	 4<<c**++
188::  	 	 	 	 	r;   c                    | j         }t          d          }t          d          }t          d          }d}d}d}t          ||d          }|                    ||           |                    ||           t	                      }	||	d<   t                      }
t          |
          }|                    |	            ||
                                d	            ||	                    d
          d           d S )Nr=   rr   rV      Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an sdlndischen Wandgemlden vorbei, gegen die rotierenden Klingen befrdert. ;   Finanni metropole se hroutily pod tlakem jejich dvtipu..    正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。r  header_namea!  Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderb?=
 =?iso-8859-1?q?and_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen?=
 =?iso-8859-1?q?_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef?=
 =?iso-8859-1?q?=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hrouti?=
 =?iso-8859-2?q?ly_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?=
 =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn44Gf44KJ?=
 =?utf-8?b?44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFzIE51bnN0dWNr?=
 =?utf-8?b?IGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5kIGRhcyBPZGVyIGRp?=
 =?utf-8?b?ZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIDjgaPjgabjgYTjgb7jgZk=?=
 =?utf-8?b?44CC?=

r  
maxlinelena	  =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerde?=
 =?iso-8859-1?q?rband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndis?=
 =?iso-8859-1?q?chen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klinge?=
 =?iso-8859-1?q?n_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se?=
 =?iso-8859-2?q?_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
 =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb?=
 =?utf-8?b?44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go?=
 =?utf-8?b?44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBp?=
 =?utf-8?b?c3QgZGFzIE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWlo?=
 =?utf-8?b?ZXJodW5kIGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI0=?=
 =?utf-8?b?44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=)
r  r
   r   appendr   r   r   r   r   r   )r6   r7   r   czutf8g_headcz_head	utf8_headr  r8   r  s              r9   test_long_nonstringz#TestLongHeaders.test_long_nonstring  s   "L!!\""w$$0	 61)444	"	D!!!iiIjjcNN			#
3<<>>  	 	 	 	188r8"" %1 	2 	2 	2 	2 	2r;   c                 r    | j         }t          dd          } ||                                d           d S )Niwasnipoop; giraffes="very-long-necked-animals"; spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"X-Foobar-Spoink-Defrobnitr$  jwasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r  r   r   r6   r7   r  s      r9   test_long_header_encodez'TestLongHeaders.test_long_header_encode  sV    " O:< < < 	188:: > 	? 	? 	? 	? 	?r;   c                 t    | j         }t          ddd          } ||                                d           d S )Nr0  r1  r  r%  r  r2  r3  r4  s      r9   <test_long_header_encode_with_tab_continuation_is_just_a_hintzLTestLongHeaders.test_long_header_encode_with_tab_continuation_is_just_a_hint  sY    " O:#') ) ) 	188:: > 	? 	? 	? 	? 	?r;   c                 t    | j         }t          ddd          } ||                                d           d S )Nziwasnipoop; giraffes="very-long-necked-animals";	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r1  r  r7  zjwasnipoop; giraffes="very-long-necked-animals";
	spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"r3  r4  s      r9   -test_long_header_encode_with_tab_continuationz=TestLongHeaders.test_long_header_encode_with_tab_continuation  s^    " O:#') ) ) 	188:: ? 	@ 	@ 	@ 	@ 	@r;   c                 v    t          dd          }|                     |                                d           d S )N   文r  =?iso-2022-jp?b?GyRCSjgbKEI=?=r   r2   r   r6   r  s     r9   0test_header_encode_with_different_output_charsetz@TestLongHeaders.test_header_encode_with_different_output_charset  s6    5(##%EFFFFFr;   c                     t          d                    d          d          }d}|                     |                                |           d S )Ns6   test-ja Ƥ줿᡼ϻʲԤξǧԤäƤޤr  z=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
 =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?=)r   rY   r2   r   )r6   r  ress      r9   5test_long_header_encode_with_different_output_charsetzETestLongHeaders.test_long_header_encode_with_different_output_charset  sV     $ %+F8$4$4h@ @7 	S)))))r;   c                     | j         }t          d          }d|d<   t                      }t          |          }|                    |            ||                                d           d S )Nr+   r0  r1  zContent-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
 spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"

)r  r   r   r   r   r   r  s        r9   test_header_splitterz$TestLongHeaders.test_header_splitter  sx    "rllH 	'( jjcNN			#
3<<>>  	 	 	 	 	r;   c                 l   | j         }t                      }d|d<   t                              d t	          d          D                       |d<   |                    d           t                      }t          |          }|                    |            ||	                                d           d S )Ntest@dom.ainr   c              3       K   | ]	}d |z  V  
dS )z<%d@dom.ain>Nr{   )r   is     r9   	<genexpr>z@TestLongHeaders.test_no_semis_header_splitter.<locals>.<genexpr>  s'      &M&Ma~'9&M&M&M&M&M&Mr;   
   
ReferencesTestzFrom: test@dom.ain
References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
 <5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>

Test)
r  r   SPACEr   rangerR   r   r   r   r   r  s        r9   test_no_semis_header_splitterz-TestLongHeaders.test_no_semis_header_splitter   s    "ii$F!JJ&M&M599&M&M&MMMLjjcNN			#
3<<>>  		 		 		 		 		r;   c                 n    | j         }t          d          } ||                                d           d S )NzSubject: the first part of this is short, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfzSubject: the first part of this is short,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr3  r4  s      r9   "test_last_split_chunk_does_not_fitz2TestLongHeaders.test_last_split_chunk_does_not_fit  S    "    	188:: b 	c 	c 	c 	c 	cr;   c                 n    | j         }t          d          } ||                                d           d S )Nz_, but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfz`,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr3  r4  s      r9   >test_splittable_leading_char_followed_by_overlong_unsplittablezNTestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittable  rS  r;   c                 n    | j         }t          d          } ||                                d           d S )Nza, , but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfzb, ,
 but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itselfr3  r4  s      r9   Gtest_multiple_splittable_leading_char_followed_by_overlong_unsplittablezWTestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittable"  rS  r;   c                 n    | j         }t          d          } ||                                d           d S )NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r3  r4  s      r9   1test_trailing_splittable_on_overlong_unsplittablezATestLongHeaders.test_trailing_splittable_on_overlong_unsplittable+  sK    " * + +
188:: * 	+ 	+ 	+ 	+ 	+r;   c                 n    | j         }t          d          } ||                                d           d S )NzW; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zX;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r3  r4  s      r9   Itest_trailing_splittable_on_overlong_unsplittable_with_leading_splittablezYTestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittable2  sS    " + , , 	188:: Z 	[ 	[ 	[ 	[ 	[r;   c                 n    | j         }t          d          } ||                                d           d S )NzpThis is a long line that has two whitespaces  in a row.  This used to cause truncation of the header when foldedzqThis is a long line that has two whitespaces  in a row.  This used to cause
 truncation of the header when foldedr3  r4  s      r9   5test_long_header_with_multiple_sequential_split_charszETestLongHeaders.test_long_header_with_multiple_sequential_split_chars;  sN    " F G G
188:: ) 	* 	* 	* 	* 	*r;   c                 n    | j         }t          d          } ||                                d           d S )NKthisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,pointsr3  r4  s      r9   :test_splitter_split_on_punctuation_only_if_fws_with_headerzJTestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_headerC  sK    " + , ,
188:: 2 	3 	3 	3 	3 	3r;   c                 n    | j         }t          d          } ||                                d           d S )Nzthis is a  test where we need to have more than one line before; our final line that is just too big to fit;; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;zthis is a  test where we need to have more than one line before;
 our final line that is just too big to fit;;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;r3  r4  s      r9   Dtest_leading_splittable_in_the_middle_just_before_overlong_last_partzTTestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_partJ  sS    " * + + 	188:: Y 	Z 	Z 	Z 	Z 	Zr;   c                 n    | j         }t          d          } ||                                d           d S )NzTthis_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself r3  r4  s      r9   /test_overlong_last_part_followed_by_split_pointz?TestLongHeaders.test_overlong_last_part_followed_by_split_pointU  sK    " * + +
188:: = 	> 	> 	> 	> 	>r;   c                 n    | j         }t          d          } ||                                d           d S )Nzthis_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zthis_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_;
 ;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r3  r4  s      r9   @test_multiline_with_overlong_parts_separated_by_two_split_pointszPTestLongHeaders.test_multiline_with_overlong_parts_separated_by_two_split_points\  S    " + , , 	188:: Z 	[ 	[ 	[ 	[ 	[r;   c                 n    | j         }t          d          } ||                                d           d S )Nzthis is a test where we need to have more than one line before our final line; ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; zthis is a test where we need to have more than one line before our final line;
 ;
 this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; r3  r4  s      r9   >test_multiline_with_overlong_last_part_followed_by_split_pointzNTestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_pointg  rg  r;   c                 F   | j         }t                      }d|d<   t                              dgdz            |d<   |                    d           t                      }t          |          }|                    |            ||                                d           d S )NrG  r   z<foo@dom.ain>  rK  rL  rM  zFrom: test@dom.ain
References: <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>   <foo@dom.ain>
   <foo@dom.ain>   <foo@dom.ain>  

Test	r  r   rN  r   rR   r   r   r   r   r  s        r9   %test_long_header_with_whitespace_runsz5TestLongHeaders.test_long_header_with_whitespace_runsr  s    "ii$F!JJ(9':R'?@@LjjcNN			#
3<<>>  		 		 		 		 		r;   c                 L   | j         }t                      }d|d<   t                              dgdz            dz   |d<   |                    d           t                      }t          |          }|                    |            ||                                d           d S )	NrG  r   z<foo@dom.ain>rK  z; abcrL  rM  zFrom: test@dom.ain
References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
 <foo@dom.ain>; abc

Testrk  r  s        r9   'test_long_run_with_semi_header_splitterz7TestLongHeaders.test_long_run_with_semi_header_splitter  s    "ii$F!JJ'82'=>>HLjjcNN			#
3<<>>  		 		 		 		 		r;   c                    | j         }t                      }d|d<   d|d<   |                    d           t                      }t	          |          }|                    |            ||                                d           d S )NrG  r   r_  rL  rM  zrFrom: test@dom.ain
References: 
 thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points

Test)r  r   rR   r   r   r   r   r  s        r9   .test_splitter_split_on_punctuation_only_if_fwsz>TestLongHeaders.test_splitter_split_on_punctuation_only_if_fws  s    "ii$F+LjjcNN			#
3<<>>  		 		 		 		 		r;   c                     | j         }d}t          |          } ||                                d           t          d          } ||                                d           d S )Nz\References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz]References:
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr3  r  s       r9   test_no_split_long_headerz)TestLongHeaders.test_no_split_long_header  ss    "(4LL 	188:: U 	V 	V 	V 8
188::ijjjjjr;   c                 v    | j         }d}t          |d          } ||                                d           d S )NaW  from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
r  r  a_  from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)
	from babylon.socal-raves.org (localhost [127.0.0.1]);
 by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
 for <mailman-admin@babylon.socal-raves.org>;
 Sat, 2 Feb 2002 17:00:06 -0800 (PST)r3  r  s       r9   "test_splitting_multiple_long_linesz2TestLongHeaders.test_splitting_multiple_long_lines  sR    "
 4...
188:: ) 	* 	* 	* 	* 	*r;   c                 z    | j         }d}t          |ddd          } ||                                d           d S )Nzfrom modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca)
	by kronos.mems-exchange.org with esmtp (Exim 4.05)
	id 17k4h5-00034i-00
	for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400N   Receivedr  )r'  r%  r  zfrom modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
 helo=cthulhu.gerg.ca)
	by kronos.mems-exchange.org with esmtp (Exim 4.05)
	id 17k4h5-00034i-00
	for test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400r3  r  s       r9   &test_splitting_first_line_only_is_longz6TestLongHeaders.test_splitting_first_line_only_is_long  sd    "A
 4BJ#') ) )
188:: A 	B 	B 	B 	B 	Br;   c                 H   | j         }t                      }t          ddd          }|                    d            ||                    d          d           ||d<    ||                    d	          d
            ||                    d	          d           d S )NzBritische Regierung gibtr=   r  r$  u-   grünes Licht für Offshore-Windkraftprojekter  r&  zl=?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
 =?iso-8859-1?q?hore-Windkraftprojekte?=maxheaderlenzwSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
 =?iso-8859-1?q?hore-Windkraftprojekte?=

r   zdSubject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?=

)r  r   r   r(  r   r   )r6   r7   r8   r  s       r9   test_long_8bit_headerz%TestLongHeaders.test_long_8bit_header  s    "ii-| )+ + +	DEEE
188r8"" %, 	- 	- 	- I
3==b=)) , 	 	 	
 	3==a=(( + 	 	 	 	 	r;   c                    | j         }t                      }d}||d<    ||                    d          d           t                      }t          |d          |d<    ||                    d          d           d S )Nuh   Britische Regierung gibt grünes Licht für Offshore-Windkraftprojekte <a-very-long-address@example.com>zReply-Torw  r{  zReply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?=
 =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?=

r$  )r  r   r   r   )r6   r7   r8   header_strings       r9    test_long_8bit_header_no_charsetz0TestLongHeaders.test_long_8bit_header_no_charset  s    "ii= (J
3==b=)) , 	 	 	
 ii -79 9 9J
3==b=)) , 	 	 	 	 	r;   c                 ~    | j         }d}t                      }||d<    ||                    d          d           d S )Nz"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>, "Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>r   rw  r{  zTo: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,
 "Someone Test #B" <someone@umich.edu>,
 "Someone Test #C" <someone@eecs.umich.edu>,
 "Someone Test #D" <someone@eecs.umich.edu>

)r  r   r   )r6   r7   r   r8   s       r9   test_long_to_headerz#TestLongHeaders.test_long_to_header  sX    ";
 iiD	
3==b=)) , 	 	 	 	 	r;   c                     | j         }d}t          |          }|                    d            ||                    d          d           d S )NzIThis is an example of string which has almost the limit of header length.zAdd another line.r  r&  z\This is an example of string which has almost the limit of header length.
 Add another line.r  r   r(  r   r6   r7   r   r  s       r9   test_long_line_after_appendz+TestLongHeaders.test_long_line_after_append  s`    "W1II	$%%%
188r8"" % 	 	 	 	 	r;   c                     | j         }d}t          |          }|                    d            ||                                d           d S )NzThis is a shorter line.z!Add another sentence. (Surprise?)z9This is a shorter line. Add another sentence. (Surprise?)r  r  s       r9   test_shorter_line_with_appendz-TestLongHeaders.test_shorter_line_with_append  s]    "%1II	4555
188::F	H 	H 	H 	H 	Hr;   c                     | j         }d}d}t          |d|          } ||                    d          d           d S )Nz!X-Very-Very-Very-Long-Header-Nameu   Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. r=   r$  r  r&  a  =?iso-8859-1?q?Die_Mieter_treten_hier_e?=
 =?iso-8859-1?q?in_werden_mit_einem_Foerderband_komfortabel_den_Korridor_e?=
 =?iso-8859-1?q?ntlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_ge?=
 =?iso-8859-1?q?gen_die_rotierenden_Klingen_bef=F6rdert=2E_?=r3  )r6   r7   fngsr  s        r9   test_long_field_namez$TestLongHeaders.test_long_field_name#  se    "0 2|444
188r8"" %A 	B 	B 	B 	B 	Br;   c                     d}t                      }t          |d          |d<   ||d<   |                     |                    d          d           d S )	Nzfrom FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700r  r  
Received-1
Received-2rw  r{  a1  Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
 hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
 Wed, 05 Mar 2003 18:10:18 -0700
Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
 hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
 Wed, 05 Mar 2003 18:10:18 -0700

r   r   r  r   r6   r  r8   s      r9   test_long_received_headerz)TestLongHeaders.test_long_received_header2  sl    / ii"1d;;;LLcmmm<< ? 	 	 	 	 	r;   c                     d}t                      }t          |dd          |d<   ||d<   |                     |                    d          d           d S )	Nz<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")r  r  r7  r  rw  r{  a#  Received-1: 
 <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
 Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
Received-2: 
 <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
 Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")

r  r  s      r9   test_string_headerinst_eqz)TestLongHeaders.test_string_headerinst_eqD  su    1 ii"1,379 9 9LLcmmm<< ? 	 	 	 	 	r;   c                     | j         }t                      }d}||d<   t          |d          |d<   d|z   |d<    ||                    d          d	           d S )
NziVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzpzFace-1zFace-2r$  r,   zFace-3rw  r{  a  Face-1: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-2: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
Face-3: 
 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp

r  r   r   r   )r6   r7   r8   ts       r9   -test_long_unbreakable_lines_with_continuationz=TestLongHeaders.test_long_unbreakable_lines_with_continuationW  s~    "iiM Hqh777HaH 	3==b=)) , 	 	 	 	 	r;   c                     | j         }d}t          j        |          } ||                    d          d           d S )NzReceived: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700rw  r{  zReceived: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
 Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700

)r  r   r  r   r6   r7   r   r8   s       r9   "test_another_long_multiline_headerz2TestLongHeaders.test_another_long_multiline_headero  sV    "/ '**
3==b=)) , 	 	 	 	 	r;   c                     | j         }d}t                      }||d<   t          |d          |d<    ||                    d          d           d S )NzList-Unsubscribe: <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>Listr$  rw  r{  a_  List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
List: List-Unsubscribe:
 <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
        <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>

r  )r6   r7   r  r8   s       r9   %test_long_lines_with_different_headerz5TestLongHeaders.test_long_lines_with_different_header|  sn    "% iiFQF333F
3==b=)) , 	 	 	 	 	r;   c                     t          t          j        d          dd          }|                     |                                dz   t          j        d          dz              d S )Nz            We're going to pretend this header is in a non-ascii character set
            	to see if line wrapping with encoded words and embedded
               folding white space worksrV   rM  )rA   r%  r*   z            =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
             =?utf-8?q?cter_set?=
             =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
             =?utf-8?q?_folding_white_space_works?=)r   r   r   r2   r   r?  s     r9   *test_long_rfc2047_header_with_embedded_fwsz:TestLongHeaders.test_long_rfc2047_header_with_embedded_fws  s    8? $, - - #%' ' ' 	D(/ ;7 +8 +8 9=	+= 	> 	> 	> 	> 	>r;   )+r  r  r  maxDiffr  r  r.  r5  r8  r:  r@  rC  rE  rP  rR  rU  rW  rY  r[  r]  r`  rb  rd  rf  ri  rl  rn  rp  rs  ru  ry  r}  r  r  r  r  r  r  r  r  r  r  r  r{   r;   r9   r  r  b  s       G  (  "42 42 42l? ? ?? ? ?@ @ @G G G* * *  (	 	 	 c c cc c cc c c+ + +[ [ [* * *3 3 3	Z 	Z 	Z> > >	[ 	[ 	[	[ 	[ 	[	 	 	"	 	 	"	 	 	$
k 
k 
k* * *,B B B   (  *  "  H H HB B B  $  &  0    &> > > > >r;   r  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestFromManglingc                 t    t                      | _        d| j        d<   | j                            d           d S )Nzaaa@bbb.orgr   z(From the desk of A.A.A.:
Blah blah blah
)r   r8   rR   r6   s    r9   setUpzTestFromMangling.setUp  sB    99(  	 	 	 	 	r;   c                     t                      }t          |d          }|                    | j                   |                     |                                d           d S )NTmangle_from_z<From: aaa@bbb.org

>From the desk of A.A.A.:
Blah blah blah
r   r   r   r8   r2   r   r6   r   r   s      r9   test_mangled_fromz"TestFromMangling.test_mangled_from  sb    JJad+++			$( ( 	 	 	 	 	r;   c                     t                      }t          |d          }|                    | j                   |                     |                                d           d S )NFr  z;From: aaa@bbb.org

From the desk of A.A.A.:
Blah blah blah
r  r  s      r9   test_dont_mangle_fromz&TestFromMangling.test_dont_mangle_from  sb    JJae,,,			$( ( 	 	 	 	 	r;   c                 ^   t                      }t          |d          }t          j        t	          j        d                    }|                    |           |                     t          d |	                                
                    d          D                       d           d S )NTr  a)              From: foo@bar.com
            Mime-Version: 1.0
            Content-Type: multipart/mixed; boundary=XXX

            From somewhere unknown

            --XXX
            Content-Type: text/plain

            foo

            --XXX--

            From somewhere unknowable
            c                 <    g | ]}|                     d           dS )z>From r   )r   r  s     r9   r   zLTestFromMangling.test_mangle_from_in_preamble_and_epilog.<locals>.<listcomp>  s8     = = =A%&\\(%;%;=a = = =r;   r*   r   )r   r   r   r  r   r   r   r2   r  r   r   )r6   r   r   r8   s       r9   'test_mangle_from_in_preamble_and_epilogz8TestFromMangling.test_mangle_from_in_preamble_and_epilog  s    JJad+++' 9 ) )    	
		# = =););D)A)A = = = > >?@	B 	B 	B 	B 	Br;   c                 @   t          j        d                              d          }t          j        |dz             }t                      }t          |d          }|                    |           |                     |	                                |dz              d S )Nz            Content-Type: text/plain; charset="utf-8"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 8bit
            From: aaa@bbb.org

        rV   s   From Rölli
Tr  s   >From Rölli
)
r   r   r   r   r   r   r   r   r2   r   )r6   r   r8   br   s        r9    test_mangled_from_with_bad_bytesz1TestFromMangling.test_mangled_from_with_bad_bytes  s     "   VG__ 	 &v0F'FGGII14000			#v0G'GHHHHHr;   c                 |    t          j        d                              d          }t          j        |          }d S )Nu               From: aperson@example.com
            Content-Type: multipart/mixed; boundary="1"
            Content-Transfer-Encoding: È
        rV   )r   r   r   r   r   )r6   r   r8   s      r9   $test_multipart_with_bad_bytes_in_ctez5TestFromMangling.test_multipart_with_bad_bytes_in_cte  s>     "   VG__	 	
 &v..r;   N)	r  r  r  r  r  r  r  r  r  r{   r;   r9   r  r    st          	 	 		 	 	B B B.I I I/ / / / /r;   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestMIMEAudioc                     t          d| d          5 }|                                | _        d d d            n# 1 swxY w Y   t          | j                  | _        d S )Nzsndhdr.r  )r&   r   
_audiodatar   _aur6   extr   s      r9   _make_audiozTestMIMEAudio._make_audio  s    ooot,, 	( ggiiDO	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(T_--   :>>c                     ddddd                                 D ]P\  }}|                     |           ||n|}|                     | j                                        d|            Qd S )Nzx-aiffzx-wavbasic)aifcaiffwavauzaudio/)r   r  r2   r  rH   r6   r  subtypes      r9   test_guess_minor_typez#TestMIMEAudio.test_guess_minor_type  s    	
 

 %''	N 	NLC S!!!$_cc'GTX6688:L7:L:LMMMM	N 	Nr;   c                     |                      d           | j                                        }|                     t	          j        t          |d                    | j                   d S )Nr  r   )r  r  rZ   r2   rW   decodebytesr   r  r6   payloads     r9   test_encodingzTestMIMEAudio.test_encoding  sg    (&&((+E'7,C,CDD	* 	* 	* 	* 	*r;   c                     |                      d           t          | j        d          }|                     |                                d           d S )Nr  fishz
audio/fish)r  r   r  r2   rH   )r6   r  s     r9   test_checkSetMinorz TestMIMEAudio.test_checkSetMinor  sO    t//,,..=====r;   c                    |                      d           | j        }| j                            ddd            || j        d         d            || j                            d          d	d
g            || j                            dd          d           g } || j                            dd          d           |                     | j                            d|d          |           |                     | j                            d|          |           |                     | j                            d|d          |           d S )Nr  rG  rH  	sndhdr.aurJ  rL  z attachment; filename="sndhdr.au"r  rH  r+   )rK  r  rK  r+   r   failobjr   rT  )r  r2   r  rN  r  rI   assertIsr6   r7   missings      r9   test_add_headerzTestMIMEAudio.test_add_header
  s   1<%0 	 	2 	2 	2
48)*-	/ 	/ 	/
48&;<< 9:	< 	< 	<
48j1FGG	 	 	
48l3HII2NNNdh((7( ) * *+2	4 	4 	4 	dh((7;;WEEEdh((w08 ) : :;B	D 	D 	D 	D 	Dr;   N)r  r  r  r  r  r  r  r  r{   r;   r9   r  r    sg        . . .
	N 	N 	N* * *> > >
D D D D Dr;   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestMIMEImagec                     t          d| d          5 }|                                | _        d d d            n# 1 swxY w Y   t          | j                  | _        d S )Nzpython.r  )r&   r   _imgdatar   _imr  s      r9   _make_imagezTestMIMEImage._make_image#  s    ooot,, 	&GGIIDM	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&T]++r  c                     d d d dd d d d ddd d d d                                 D ]P\  }}|                     |           ||n|}|                     | j                                        d|            Qd S )Njpegrastrgb)bmpexrgifjpgpbmpgmpngppmrassgitiffwebpxbmzimage/)r   r  r2   r  rH   r  s      r9   r  z#TestMIMEImage.test_guess_minor_type(  s    
 
 %''	N 	NLC S!!!$_cc'GTX6688:L7:L:LMMMM#	N 	Nr;   c                     |                      d           | j                                        }|                     t	          j        t          |d                    | j                   d S )Nr  r   )r  r  rZ   r2   rW   r  r   r  r  s     r9   r  zTestMIMEImage.test_encoding<  sg    (&&((+E'7,C,CDD	( 	( 	( 	( 	(r;   c                     |                      d           t          | j        d          }|                     |                                d           d S )Nr  r  z
image/fish)r  r   r  r2   rH   )r6   ims     r9   r  z TestMIMEImage.test_checkSetMinorB  sO    t}f--,,..=====r;   c                    |                      d           | j        }| j                            ddd            || j        d         d            || j                            d          d	d
g            || j                            dd          d           g } || j                            dd          d           |                     | j                            d|d          |           |                     | j                            d|          |           |                     | j                            d|d          |           d S )Nr  rG  rH  r   rJ  rL  z%attachment; filename="dingusfish.gif"r  r  )rK  r   rK  r+   r   r  rT  )r  r2   r  rN  r  rI   r  r  s      r9   r  zTestMIMEImage.test_add_headerG  s   1<%5 	 	7 	7 	7
48)*2	4 	4 	4
48&;<< >?	A 	A 	A
48j1FGG	 	 	
48l3HII2NNNdh((0E ) G GHO	Q 	Q 	Q 	dh((7;;WEEEdh((w08 ) : :;B	D 	D 	D 	D 	Dr;   N)r  r  r  r  r  r  r  r  r{   r;   r9   r  r  "  sg        , , ,
N N N(( ( (> > >
D D D D Dr;   r  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	TestMIMEApplicationc                     | j         }t          d          } ||                                d            ||d         d           d S )N   r\  rB   rW   )r2   r   rH   r5   s      r9   test_headersz TestMIMEApplication.test_headers^  sU    9::
3!!#=>>>
3*+X66666r;   c                     | j         }d}t          |          } ||                                                                d            ||                    d          |           d S )Nr  z+vv8/f7/TrX   )r2   r   rZ   strip)r6   r7   	bytesdatar8   s       r9   	test_bodyzTestMIMEApplication.test_bodyd  sj    /	i((
3??""$$j111
3??$?''33333r;   c                    d}t          |t          j                  }|                     |                                dt          |          z             |                     |                    d          |           |                     |d         d           t                      }t          |          }|                    |           |	                                }t          j        |          }|                     |                                dt          |          z             |                     |                    d          |           |                     |d         d           d S )Nr  _encoder   �TrX   rE   r`   )r   r   encode_7or8bitr2   rZ   r  r   r   r   r   r   r   r6   r  r8   r   r   wireformmsg2s          r9   $test_binary_body_with_encode_7or8bitz8TestMIMEApplication.test_binary_body_with_encode_7or8bitl  s=   /	i(2IJJJ**Hs9~~,EFFF55yAAA896BBBII1			#::<<'11**Hs9~~,EFFF)))66	BBB9:FCCCCCr;   c                 |   d}t          |t          j                  }|                     |                                dt          |          z             |                     |                    d          |           t                      }t          |          }|                    |           |	                                }t          j        |          }|                     |                                dt          |          z             |                     |                    d          |           d S )Nr  r  r  TrX   )r   r   encode_noopr2   rZ   r  r   r   r   r   r   r   r  s          r9   !test_binary_body_with_encode_noopz5TestMIMEApplication.test_binary_body_with_encode_noop}  s    0	i(2FGGG**Hs9~~,EFFF55yAAAII1			#::<<'11**Hs9~~,EFFF)))66	BBBBBr;   c                    d}t          |t          j                  }|                     |                    d          |           t                      }t          |          }|                    |           |                                }t          j
        |          }|                     |                    d          |           d S )Ns   r  TrX   )r   r   r  r2   rZ   r   r   r   r   r   r   r  s          r9   0test_binary_body_with_unicode_linend_encode_noopzDTestMIMEApplication.test_binary_body_with_unicode_linend_encode_noop  s    3	i(2FGGG55yAAAII1			#::<<'11)))66	BBBBBr;   c                    d}t          |t          j                  }|                     |                                d           |                     |                    d          |           |                     |d         d           t                      }t          |          }|                    |           |                                }t          j
        |          }|                     |                                d           |                     |                    d          |           |                     |d         d           d S )Ns    r  z=FA=FB=FC=FD=FE=FF=20TrX   rE   rC   )r   r   encode_quoprir2   rZ   r   r   r   r   r   r   r  s          r9   #test_binary_body_with_encode_quopriz7TestMIMEApplication.test_binary_body_with_encode_quopri  s+   0	i(2HIII**,CDDD55yAAA89;MNNNII1			#::<<'11**,CDDD)))66	BBB9:<NOOOOOr;   c                 <   d}t          |t          j                  }|                     |                                d           |                     |                    d          |           t                      }t          |          }|                    |           |                                }t          j
        |          }|                     |                                d           |                     |                    d          |           d S )Nr  r  z	+vv8/f7/
TrX   )r   r   encode_base64r2   rZ   r   r   r   r   r   r   r  s          r9   #test_binary_body_with_encode_base64z7TestMIMEApplication.test_binary_body_with_encode_base64  s    /	i(2HIII**L99955yAAAII1			#::<<'11**L999)))66	BBBBBr;   N)
r  r  r  r  r  r  r	  r  r  r  r{   r;   r9   r  r  ]  s        7 7 74 4 4D D D"C C C"
C 
C 
CP P P C C C C Cr;   r  c                   j    e Zd Zd Zd Zd Zd Zd Zd Zd Z	 e
j        d          d	             Zd
S )TestMIMETextc                 .    t          d          | _        d S Nhello there)r   _msgr  s    r9   r  zTestMIMEText.setUp  s    ]++			r;   c                 f   | j         } || j                                        d            || j                            d          d           g }|                     | j                            d|          |           |                     | j                            d|d          |           d S )Nr?   rA   rN   rT  r  )r2   r  rH   rI   r  r  s      r9   
test_typeszTestMIMEText.test_types  s    
49%%''666
49y)):666di))(G<<gFFFdi)))WX)NN	 	 	 	 	r;   c                     |                      | j                                        d           |                     | j                                                   d S r  )r2   r  rZ   assertFalseis_multipartr  s    r9   test_payloadzTestMIMEText.test_payload  sN    ..00-@@@//1122222r;   c                    | j         }t          dd          } ||                                j        d            ||d         d           t	          d          }d |_        t          d|          } ||                                j        d            ||d         d            ||                                d           d S )Nr  rN   r  r@   rO   rV   r  )r2   r   rF   rJ   r
   ra   rZ   rK   s       r9   test_charsetzTestMIMEText.test_charset  s    }z:::
3??*J777
3~ @AAA'"" $}w777
3??*G444
3~ =>>>
3??m,,,,,r;   c                     | j         }t          dd          } ||                                j        d            ||d         d           d S )Nr  rN   r  r@   rO   )r2   r   rF   rJ   r5   s      r9   test_7bit_inputzTestMIMEText.test_7bit_input  sY    }z:::
3??*J777
3~ @AAAAAr;   c                     | j         }t          d          } ||                                d            ||d         d           |                     d|                                           d S )Nr  rN   r@   rO   )r2   r   rF   r   r   r5   s      r9   test_7bit_input_no_charsetz'TestMIMEText.test_7bit_input_no_charset  sm    }%%
3??j)))
3~ @AAAmS]]__55555r;   c                 
   d}| j         }t          |d          } ||                                j        d            ||d         d            ||                    d          |                    d                     d S )N   кирилицаrV   r  r@   r  TrX   )r2   r   rF   output_charsetrZ   r   )r6   teststrr7   r8   s       r9   test_utf8_inputzTestMIMEText.test_utf8_input  s    Dw111
3??+W555
3~ =>>>
3??$?'')@)@AAAAAr;   zBcan't fix because of backward compat in email5, will fix in email6c                 L    d}|                      t          t          |           d S )Nr%  )r   UnicodeEncodeErrorr   )r6   r'  s     r9   test_utf8_input_no_charsetz'TestMIMEText.test_utf8_input_no_charset  s)     E,h@@@@@r;   N)r  r  r  r  r  r  r  r!  r#  r(  unittestskipr+  r{   r;   r9   r  r    s        , , ,  3 3 3- - -B B B6 6 6B B B X]   A A A A Ar;   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestMultipartc                    t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          ddd          }t          |d          }|                    d	d
d           t          d          }|                    |           |                    |           d|d<   d|d<   d|d<   d}t          j        |          }|d         dk    rt          j	        }nt          j
        }|dk    rd}	nd}	d|	|dz  fz  }
t          j        dt          j        |                    |
z   |d<   || _        || _        || _        d S )Nr  r  	multipartmixedr   r  r   )r&  rL  rH  rJ  z$Hi there,

This is the dingus fish.
zBarry <barry@digicool.com>r   z)Dingus Lovers <cravindogs@cravindogs.com>r   zHere is your dingus fishr  g4FcpAr   -+z %s%04d$   z%a, %d %b %Y %H:%M:%SDate)r&   r   r   r   rN  r   rn   time	localtimetimezonealtzonestrftimer  r  _txt)r6   r   r\   	containerr  intronow	timetupletzsecssigntzoffsets              r9   r  zTestMultipart.setUp  s   lD)) 	R7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	['JGGG	$%5666."2 	 	4 	4 	4   
 	8	&E	$9	) N3''	R=A]FF\FA::DDDfrk22 M#N3! !#+,	& 				r  c                    | j         }| j        }| j        }|                     |                                            ||                                d            |t          |                                          d            |t          |j        d           |                    d          }|                    d          }| 	                    || j
                   | 	                    || j                    ||                                ||g           |                     |                                           |                     |                                           d S )Nrk   r   r   r   )r2   r   r  r   r  rH   r  rZ   
IndexErrorr  r>  r  r  )r6   r7   raisesr   m0m1s         r9   test_hierarchyzTestMultipart.test_hierarchy  s:   "I(()))
1!2333
3q}}###z1=!,,,]]1]]1b$)$$$b$(###
1==??RH%%%**+++**+++++r;   c                     d}t                                          |          }|                     ||                                           d S )NzContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY


--BOUNDARY--
)r   r   r  r   )r6   r   r8   s      r9   test_empty_multipart_idempotentz-TestMultipart.test_empty_multipart_idempotent,  sF     hh%%dCMMOO44444r;   c                     t          dd          }d|d<   d|d<   d|d<   |                    d	           |                     |                                d
           d S )Nr1  r2  	A subjectr  aperson@dom.ainr   bperson@dom.ainr   r   zContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY

--BOUNDARY--
)r   r   r  r   r6   outers     r9   /test_no_parts_in_a_multipart_with_none_epiloguez=TestMultipart.test_no_parts_in_a_multipart_with_none_epilogue=  st    g..&i'd)f:&&&eoo// 
2 
	 
	 
	 
	 
	r;   c                     t          dd          }d|d<   d|d<   d|d<   d	|_        d	|_        |                    d
           |                     |                                d           d S )Nr1  r2  rO  r  rP  r   rQ  r   r+   r   zContent-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY

--BOUNDARY--
)r   preambleepiloguer   r  r   rR  s     r9   0test_no_parts_in_a_multipart_with_empty_epiloguez>TestMultipart.test_no_parts_in_a_multipart_with_empty_epilogueO  s    g..&i'd)f:&&&eoo// 2 	 	 	 	 	r;   c                     | j         }t          dd          }d|d<   d|d<   d|d<   |                    d	           t          d
          }|                    |            ||                                d           d S )Nr1  r2  rO  r  rP  r   rQ  r   r   r    Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--
)r  r   r   r   rn   r   r6   r7   rS  r8   s       r9   test_one_part_in_a_multipartz*TestMultipart.test_one_part_in_a_multipartd  s    "g..&i'd)f:&&&}%%S
5??  	 	 	 	 	r;   c                    | j         }t          dd          }d|d<   d|d<   d|d<   d	|_        t          d
          }|                    |           |                    d            ||                                d           d S )Nr1  r2  rO  r  rP  r   rQ  r   r+   r  r   a  Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain


--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--
r  r   rV  r   rn   r   r   r[  s       r9   1test_seq_parts_in_a_multipart_with_empty_preamblez?TestMultipart.test_seq_parts_in_a_multipart_with_empty_preamble}  s    "g..&i'd)f}%%S:&&&
5??  	 	 	 	 	r;   c                    | j         }t          dd          }d|d<   d|d<   d|d<   d |_        t          d	          }|                    |           |                    d
            ||                                d           d S Nr1  r2  rO  r  rP  r   rQ  r   r  r   rZ  r^  r[  s       r9   0test_seq_parts_in_a_multipart_with_none_preamblez>TestMultipart.test_seq_parts_in_a_multipart_with_none_preamble      "g..&i'd)f}%%S:&&&
5??  	 	 	 	 	r;   c                    | j         }t          dd          }d|d<   d|d<   d|d<   d |_        t          d	          }|                    |           |                    d
            ||                                d           d S ra  r  r   rW  r   rn   r   r   r[  s       r9   0test_seq_parts_in_a_multipart_with_none_epiloguez>TestMultipart.test_seq_parts_in_a_multipart_with_none_epilogue  rc  r;   c                    | j         }t          dd          }d|d<   d|d<   d|d<   d	|_        t          d
          }|                    |           |                    d            ||                                d           d S )Nr1  r2  rO  r  rP  r   rQ  r   r+   r  r   rZ  re  r[  s       r9   1test_seq_parts_in_a_multipart_with_empty_epiloguez?TestMultipart.test_seq_parts_in_a_multipart_with_empty_epilogue  s    "g..&i'd)f}%%S:&&&
5??  	 	 	 	 	r;   c                    | j         }t          dd          }d|d<   d|d<   d|d<   d	|_        t          d
          }|                    |           |                    d            ||                                d           d S )Nr1  r2  rO  r  rP  r   rQ  r   r*   r  r   a  Content-Type: multipart/mixed; boundary="BOUNDARY"
MIME-Version: 1.0
Subject: A subject
To: aperson@dom.ain
From: bperson@dom.ain

--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

hello world
--BOUNDARY--

re  r[  s       r9   .test_seq_parts_in_a_multipart_with_nl_epiloguez<TestMultipart.test_seq_parts_in_a_multipart_with_nl_epilogue  s    "g..&i'd)f}%%S:&&&
5??  	 	 	 	 	r;   c                 v   | j         }|                     d          } |t          |                                          d           |                    d          } ||                                d            |t          |                                          d           |                                D ]~} ||                                d            |t          |                                          d           |                    d          } ||                                d           d S )N
msg_36.txtr   r   zmultipart/alternativezmessage/external-bodyr   r?   )r2   r3   r  rZ   rH   )r6   r7   r8   msg1r   
subsubparts         r9   test_message_external_bodyz(TestMultipart.test_message_external_body  s3   ll<((
3s  !!1%%%q!!
4  ""$;<<<
3t!!""A&&&'')) 	< 	<GBw''))+BCCCBs7&&(())1--- ,,Q//JBz**,,l;;;;		< 	<r;   c                     |                      d          }|                     t          |                                          d           d S )Nz
msg_37.txtr   )r3   r2   r  rZ   rh   s     r9   test_double_boundaryz"TestMultipart.test_double_boundary  sC     ll<((S__..//33333r;   c                     | j         }|                     d          }t                      }t          j        ||            ||                                d           d S )Nz
msg_38.txtzmultipart/mixed
    multipart/mixed
        multipart/alternative
            text/plain
        text/plain
    text/plain
    text/plain
r  r3   r   r!   
_structurer   r6   r7   r8   r  s       r9   )test_nested_inner_contains_outer_boundaryz7TestMultipart.test_nested_inner_contains_outer_boundary  sf    "
 ll<((jjS#&&&
3<<>>  	 	 	 	 	r;   c                     | j         }|                     d          }t                      }t          j        ||            ||                                d           d S )Nz
msg_39.txtzmultipart/mixed
    multipart/mixed
        multipart/alternative
        application/octet-stream
        application/octet-stream
    text/plain
rs  ru  s       r9   test_nested_with_same_boundaryz,TestMultipart.test_nested_with_same_boundary,  sf    " ll<((jjS#&&&
3<<>>  	 	 	 	 	r;   c                     |                      d          }|                     |                                d           d S )Nz
msg_40.txtzMIME-Version: 1.0
Content-Type: text/html; boundary="--961284236552522269"

----961284236552522269
Content-Type: text/html;
Content-Transfer-Encoding: 7Bit

<html></html>

----961284236552522269--
)r3   r2   r   rh   s     r9   test_boundary_in_non_multipartz,TestMultipart.test_boundary_in_non_multipart=  sD    ll<(( + 	 	 	 	 	r;   c                    | j         }t          j        d          }|                     |                                            ||                                d            |t          |                                          d           d S )NzMIME-Version: 1.0
Content-Type: multipart/mixed; boundary="    XXXX"

--    XXXX
Content-Type: text/plain


--    XXXX
Content-Type: text/plain

--    XXXX--
z    XXXXr   )r2   r   r  r   r  r   r  rZ   r5   s      r9    test_boundary_with_leading_spacez.TestMultipart.test_boundary_with_leading_spaceL  s    ' )   	((**+++
3z***
3s  !!1%%%%%r;   c                     t                                          d          }|                     |                    d                                          d           d S )NzContent-Type: multipart/mixed; boundary="===============0012394164=="
MIME-Version: 1.0

--===============0012394164==
Content-Type: image/file1.jpg
MIME-Version: 1.0
Content-Transfer-Encoding: base64

YXNkZg==
--===============0012394164==--r   zYXNkZg==)r   r   r2   rZ   r  s     r9   &test_boundary_without_trailing_newlinez4TestMultipart.test_boundary_without_trailing_newline_  sV    HH 
# 
$ 
$ 	q))5577DDDDDr;   c                 z    t          dd          }|                     |j        t          j        j                   d S )Nr1  r2  )r   r  r   r   compat32r  s     r9   test_mimebase_default_policyz*TestMultipart.test_mimebase_default_policym  s2    ['**ah 566666r;   c                     t          ddt          j        j                  }|                     |j        t          j        j                   d S )Nr1  r2  r   )r   r   r   defaultr  r  s     r9   test_mimebase_custom_policyz)TestMultipart.test_mimebase_custom_policyq  s<    ['%,2FGGGah 455555r;   N)r  r  r  r  rK  rM  rT  rX  r\  r_  rb  rf  rh  rj  ro  rq  rv  rx  rz  r|  r~  r  r  r{   r;   r9   r/  r/    sD       " " "H, , ,$5 5 5"  $  *  2  8  6  6  6  6< < <4 4 4  &  "  & & &&E E E7 7 76 6 6 6 6r;   r/  c                   |    e Zd Zd Zd Zd Z ej        d          Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd ZdS )TestNonConformantc                     | j         }|                     d          } ||                                d            ||                                d            ||                                d           d S )Nz
msg_14.txtr?   r   r  )r2   r3   rH   rt  r  r5   s      r9   test_parse_missing_minor_typez/TestNonConformant.test_parse_missing_minor_typex  s{    ll<((
3!!<000
3##%%v...
3""$$g.....r;   c                 F   |                      d          }|                    d          }|                     t          |d                     |                     t          |j                  d           |                     |j        d         t          j	                   d S )N
msg_15.txtr   r  r   )
r3   rZ   r   hasattrr2   r  r  r  r    StartBoundaryNotFoundDefect)r6   r8   inners      r9   test_same_boundary_inner_outerz0TestNonConformant.test_same_boundary_inner_outer  s    ll<((""y11222U]++Q///emA.$@	B 	B 	B 	B 	Br;   c                    |                      d          }|                     |                                t                     |                     t          |j                  d           |                     |j        d         t          j                   |                     |j        d         t          j	                   d S )Nz
msg_25.txtr   r   r   )
r3   r  rZ   r   r2   r  r  r    NoBoundaryInMultipartDefect!MultipartInvariantViolationDefectrh   s     r9   test_multipart_no_boundaryz,TestNonConformant.test_multipart_no_boundary  s    ll<((coo//555S[))1---ck!n$@	B 	B 	Bck!n$F	H 	H 	H 	H 	Hr;   a^          Date: Wed, 14 Nov 2007 12:56:23 GMT
        From: foo@bar.invalid
        To: foo@bar.invalid
        Subject: Content-Transfer-Encoding: base64 and multipart
        MIME-Version: 1.0
        Content-Type: multipart/mixed;
            boundary="===============3344438784458119861=="{}

        --===============3344438784458119861==
        Content-Type: text/plain

        Test message

        --===============3344438784458119861==
        Content-Type: application/octet-stream
        Content-Transfer-Encoding: base64

        YWJj

        --===============3344438784458119861==--
        c                    |                      | j                            d                    }|                     t	          |j                  d           |                     |j        d         t          j                   d S )Nz"
Content-Transfer-Encoding: base64r   r   )	_str_msgmultipart_msgr  r2   r  r  r  r    -InvalidMultipartContentTransferEncodingDefectrh   s     r9   test_multipart_invalid_ctez,TestNonConformant.test_multipart_invalid_cte  s    mm%%&KLLN NS[))1---ck!n@	B 	B 	B 	B 	Br;   c                     |                      | j                            d                    }|                     t	          |j                  d           d S )Nr+   r   r  r  r  r2   r  r  rh   s     r9   test_multipart_no_cte_no_defectz1TestNonConformant.test_multipart_no_cte_no_defect  sJ    mmD.55b99::S[))1-----r;   c                     dD ]j}|                      | j                            d                    |                              }|                     t	          |j                  d           kd S )N)r  r`   BINaryz
Content-Transfer-Encoding: {}r   r  )r6   r   r8   s      r9   "test_multipart_valid_cte_no_defectz4TestNonConformant.test_multipart_valid_cte_no_defect  s~    - 	2 	2C--"))5<<SAAC CD DC S--q1111		2 	2r;   c                 `   | j         }| j        }t                      }d|d<    ||                                d            ||                                d            ||                                d           |d= d|d<    ||                                d            ||                                d            ||                                d           t                      }t          |          }|                    |            ||	                                d           d S )Nr   rD   r  r?   r@   r   zContent-Type: foo

)
r2   r  r   rt  r  rH   r   r   r   r   )r6   r7   neqr8   r   r   s         r9   test_invalid_content_typez+TestNonConformant.test_invalid_content_type  s/   #ii$N
3##%%v...
3""$$g...
3!!<000#N
3##%%v...
3""$$g...
3!!<000JJaLL			#AJJLL122222r;   c                 z    | j         }|                     d          } ||                                d           d S )N
msg_31.txtzm--BOUNDARY
Content-Type: text/plain

message 1

--BOUNDARY
Content-Type: text/plain

message 2

--BOUNDARY--
)r  r3   rZ   r5   s      r9   test_no_start_boundaryz(TestNonConformant.test_no_start_boundary  sJ    "ll<((
3??  	 	 	 	 	r;   c                 z    | j         }|                     d          } ||                                d           d S )Nz
msg_35.txtzFrom: aperson@dom.ain
To: bperson@dom.ain
Subject: here's something interesting

counter to RFC 2822, there's no separating newline here
)r  r3   r   r5   s      r9   test_no_separating_blank_linez/TestNonConformant.test_no_separating_blank_line  sH    "ll<((
3==??  	 	 	 	 	r;   c                 r   |                      d          }|                     t          |d                     |                     t	          |j                  d           |                     |j        d         t          j                   |                     |j        d         t          j	                   d S )Nz
msg_41.txtr  r   r   r   )
r3   r   r  r2   r  r  r  r    r  r  rh   s     r9   test_lying_multipartz&TestNonConformant.test_lying_multipart  s    ll<((Y//000S[))1---ck!n$@	B 	B 	Bck!n$F	H 	H 	H 	H 	Hr;   c                 &   |                      d          }|                    d                              d          }|                     t          |j                  d           |                     |j        d         t          j                   d S )Nz
msg_42.txtr   r   )r3   rZ   r2   r  r  r  r    r  )r6   rS  bads      r9   test_missing_start_boundaryz-TestNonConformant.test_missing_start_boundary  s    \** ""..q11S[))1---ck!n$@	B 	B 	B 	B 	Br;   c                 z   | j         }d}t          j        |          } ||                                dg            ||                                d            |t          |j                  d           |                     |j        t          j	        g            ||j        d         j
        d           d S )Nz Line 1
Subject: test

bodyr  bodyr   r   z Line 1
)r2   r   r  r  rZ   r  r  assertDefectsEqualr    #FirstHeaderLineIsContinuationDefectliner  s       r9   &test_first_line_is_continuation_headerz8TestNonConformant.test_first_line_is_continuation_header	  s    ,'**
388::	{###
3??f%%%
3s{Q"("L!M	O 	O 	O
3;q>,,,,,r;   c                    |                      d          }|                     |                                dg           |                     |                                d           |                     |j        t          j        g           d S )Nz&Subject: test
not a header
To: abc

b
r  znot a header
To: abc

b
)r  r2   r  rZ   r  r  r     MissingHeaderBodySeparatorDefectrh   s     r9   "test_missing_header_body_separatorz4TestNonConformant.test_missing_header_body_separator	  s    
 mmIJJi[111**,JKKK!'!H I	K 	K 	K 	K 	Kr;   N)r  r  r  r  r  r  r   r   r  r  r  r  r  r  r  r  r  r  r  r{   r;   r9   r  r  v  s       / / /B B BH H H $HO %  M0B B B. . .
2 2 23 3 3*  "	 	 	H H HB B B 	- 	- 	-	K 	K 	K 	K 	Kr;   r  c                   n    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )TestRFC2047c                     | j         }d}t          |          } ||g d           t          |          } |t          |          d           |                     |                    d          d           d S )NzVRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
 foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=))s   Re: Ns
   rksmrgszmac-iceland)s    baz foo bar Nr  u+   Re: räksmörgås baz foo bar räksmörgåsr  r&  ziRe: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
 =?mac-iceland?q?=9Arg=8Cs?=)r2   r   r   r   r  r   r6   r7   r   dhr   s        r9   test_rfc2047_multilinez"TestRFC2047.test_rfc2047_multiline&	  s    /1
2 5 5 5 	6 	6 	6
 R
3v;;D	F 	F 	Ffmmrm:: =  	! 	! 	! 	! 	!r;   c                     | j         }d}t          |          } ||ddg           t          t          |                    } ||d           d S )Nz0=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>)s   Andrr=   )s    Pirard <pirard@dom.ain>Nu   André Pirard <pirard@dom.ain>r2   r   r   r   r  s        r9   test_whitespace_keeper_unicodez*TestRFC2047.test_whitespace_keeper_unicode7	  si    >1
2+35 	6 	6 	6[__%%
6566666r;   c                     | j         }d}t          |          } ||g d           t          t          |                    } ||d           d S )NzWThe =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?=))s   The N)s   quick brown foxr=   )s    jumped over the N)s   lazy dogr=   z,The quick brown fox jumped over the lazy dogr  )r6   r7   r   r  hus        r9    test_whitespace_keeper_unicode_2z,TestRFC2047.test_whitespace_keeper_unicode_2@	  ss    e1
2 K K K 	L 	L 	LR!!
2=>>>>>r;   c                 X    d}t          |          }|                     |g d           d S )Nz3Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord))s   SmN   r=   )s   rgN   r=   )s   sbordNr   r2   r6   r   r  s      r9   test_rfc2047_missing_whitespacez+TestRFC2047.test_rfc2047_missing_whitespaceI	  sG    A1 0 0 0 	1 	1 	1 	1 	1r;   c                 X    d}t          |          }|                     |g d           d S )Nz7Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord))s   Sm Nr  )s    rg Nr  )s    sbordNr  r  s      r9   test_rfc2047_with_whitespacez(TestRFC2047.test_rfc2047_with_whitespaceP	  sG    E1 1 1 1 	2 	2 	2 	2 	2r;   c                 x    d}g d}|D ]0\  }}t          ||z            }|                     ||dfg           1d S )Nz=?iso-8859-1?B?%s?=))zdm==   v)zdm=r  )dmr  )zdmk=   vi)dmkr  r=   r  )r6   r   r\   qar  s         r9   test_rfc2047_B_bad_paddingz&TestRFC2047.test_rfc2047_B_bad_paddingW	  si    !    	6 	6DAqq1u%%BR1l"3!45555	6 	6r;   c                 R    d}|                      t          |          dg           d S )Nz=?iso-8859-1?Q?andr=e9=zz?=)s   andr=zzr=   r2   r   r6   r   s     r9   test_rfc2047_Q_invalid_digitsz)TestRFC2047.test_rfc2047_Q_invalid_digitsa	  s9    )q))78	: 	: 	: 	: 	:r;   c                 T    d}|                      t          |          g d           d S )Nz(=?ISO-8859-1?Q?a?=))   (N   ar=      )Nr  r  s     r9   test_rfc2047_rfc2047_1z"TestRFC2047.test_rfc2047_rfc2047_1g	  sA    "q))>>>	@ 	@ 	@ 	@ 	@r;   c                 T    d}|                      t          |          g d           d S )Nz(=?ISO-8859-1?Q?a?= b))r  r  )s    b)Nr  r  s     r9   test_rfc2047_rfc2047_2z"TestRFC2047.test_rfc2047_rfc2047_2m	  A    $q))@@@	B 	B 	B 	B 	Br;   c                 T    d}|                      t          |          g d           d S )Nz'(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)r  )s   abr=   r  r  r  s     r9   test_rfc2047_rfc2047_3z"TestRFC2047.test_rfc2047_rfc2047_3s	  sA    5q))???	A 	A 	A 	A 	Ar;   c                 T    d}|                      t          |          g d           d S )Nz((=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)r  r  r  s     r9   test_rfc2047_rfc2047_4z"TestRFC2047.test_rfc2047_rfc2047_4y	  sA    6q))???	A 	A 	A 	A 	Ar;   c                 T    d}|                      t          |          g d           d S )Nz,(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r  r  r  s     r9   test_rfc2047_rfc2047_5az#TestRFC2047.test_rfc2047_rfc2047_5a	  sA    <q))???	A 	A 	A 	A 	Ar;   c                 T    d}|                      t          |          g d           d S )Nz+(=?ISO-8859-1?Q?a?=
    =?ISO-8859-1?Q?b?=)r  r  r  s     r9   test_rfc2047_rfc2047_5bz#TestRFC2047.test_rfc2047_rfc2047_5b	  sA    :q))???	A 	A 	A 	A 	Ar;   c                 T    d}|                      t          |          g d           d S )Nz(=?ISO-8859-1?Q?a_b?=))r  )s   a br=   r  r  r  s     r9   test_rfc2047_rfc2047_6z"TestRFC2047.test_rfc2047_rfc2047_6	  r  r;   c           	      v   d}|                      t          |          g d           |                      t          t          |                                                    |                                           |                      t          t          t          |                              d           d S )Nz((=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=))r  r  )s    brr   r  z(a b))r2   r   r   r   r   r   r  s     r9   test_rfc2047_rfc2047_7z"TestRFC2047.test_rfc2047_rfc2047_7	  s    6q))  	 	 	 	]1%5%566==??KKK[q)9)9::;;WEEEEEr;   c           	         d}|                      t          |          ddg           |                      t          t          |                                                    d                    |                                                     |                      t          t          t          |                              d           d S )Nz9=?windows-1252?q?=22M=FCller_T=22?=
 <T.Mueller@xxx.com>)s
   "Mller T"zwindows-1252)s   <T.Mueller@xxx.com>Nr+   u   "Müller T" <T.Mueller@xxx.com>)r2   r   r   r   r   
splitlinesr   r  s     r9   test_multiline_headerz!TestRFC2047.test_multiline_header	  s    Iq))/+-	. 	. 	. 	]1%5%566==??00	2 	2 	2[q)9)9::;;:	< 	< 	< 	< 	<r;   N)r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r{   r;   r9   r  r  %	  s       ! ! !"7 7 7? ? ?1 1 12 2 26 6 6: : :@ @ @B B BA A AA A AA A AA A AB B BF F F< < < < <r;   r  c                   n    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )TestMIMEMessagec                     t          dd          5 }|                                | _        d d d            d S # 1 swxY w Y   d S )N
msg_11.txtrV   r   )r&   r   _textr6   r   s     r9   r  zTestMIMEMessage.setUp	  s    lW555 	#DJ	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   9= =c                 H    |                      t          t          d           d S )Nza plain string)r   rm   r   r  s    r9   test_type_errorzTestMIMEMessage.test_type_error	  s!    )[2BCCCCCr;   c                    | j         }d}t                      }||d<   t          |          } ||                                d           |                                }|                     |t                      |t          |          d           |d         }|                     ||            ||d         |           d S )NzA sub-messager  ra  r   r   subject)	r2   r   r   rH   rZ   r  listr  r  )r6   r7   r  r   rr  r   s          r9   test_valid_argumentz#TestMIMEMessage.test_valid_argument	  s    !II)NN
1!1222--//gt,,,
3w<<!*gq!!!
79w'''''r;   c                     t                      }d|d<   t                      }d|d<   t          |          }|                     t          j        |j        |           d S )N	subpart 1r  z	subpart 2)r   r   r   r    MultipartConversionErrorrn   )r6   rm  r  r  s       r9   test_bad_multipartz"TestMIMEMessage.test_bad_multipart	  sV    yy%Yyy%Y&918TJJJJJr;   c                 2   t                      }d|d<   |                    d           t          |          }d|d<   t                      }t	          |          }|                    |           |                     |                                d           d S )NAn enclosed messager  !Here is the body of the message.
zThe enclosing messagezContent-Type: message/rfc822
MIME-Version: 1.0
Subject: The enclosing message

Subject: An enclosed message

Here is the body of the message.
)r   rR   r   r   r   r   r2   r   )r6   r   r  r   r   s        r9   test_generatezTestMIMEMessage.test_generate	  s    II,)	:;;;NN.)JJaLL			! ( 	 	 	 	 	r;   c                    | j         }|                     d          } ||                                d           |                                }|                     |t
                      |t          |          d           |d         }|                     |t                      ||d         d            ||                                d           d S )Nr  ra  r   r   r  r  r  )r2   r3   rH   rZ   r  r  r  r   )r6   r7   r8   r  submsgs        r9   test_parse_message_rfc822z)TestMIMEMessage.test_parse_message_rfc822	  s    ll<((
3!!#3444//##gt,,,
3w<<fg...
6)3444
6!EFFFFFr;   c                 *   | j         }|                     d          } ||                                d           |                     |                                            |t          |                                          d           |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            |t          |                                          d	           |                    d          }|                     |t                      ||d
         d            ||	                    dd          d            ||	                    dd          d            |                    d          }|                     |t                      ||d         d            ||
                    d          ddg            ||	                    dd          d           |                    d	          } ||                                d           |                                }|                     |t                      |t          |          d           |d         }|                     |t                      ||                                d            ||d         d           d S )N
msg_16.txtr>  r   r   r?   a  This report relates to a message you sent with the following header fields:

  Message-id: <002001c144a6$8752e060$56104586@oxy.edu>
  Date: Sun, 23 Sep 2001 20:10:55 -0700
  From: "Ian T. Henry" <henryi@oxy.edu>
  To: SoCal Raves <scr@socal-raves.org>
  Subject: [scr] yeah for Ians!!

Your message cannot be delivered to the following recipients:

  Recipient address: jangel1@cougar.noc.ucla.edu
  Reason: recipient reached disk quota

r   zmessage/delivery-statusr   zoriginal-envelope-idz"0GK500B4HD0888@cougar.noc.ucla.edudnszreporting-mtar  r+   nsdactionfailedzoriginal-recipient)r  r+   )zjangel1@cougar.noc.ucla.edur+   r  zfinal-recipientra  
message-idz(<002001c144a6$8752e060$56104586@oxy.edu>)r2   r3   rH   r   r  r  rZ   r  r   rI   r  r  )r6   r7   r8   r   dsn1dsn2r  rn  s           r9   test_dsnzTestMIMEMessage.test_dsn	  s   ll<((
3!!#5666((**+++
3s  !!1%%%//!$$
7##%%|444
7   # 	 	 	$ //!$$
7##%%'@AAA
3w""$$%%q))) ""1%%dG,,,
4&')MNNN
4>>%>88"===
4>>%>88$???""1%%dG,,,
4>8$$$
4??"6?77?@	B 	B 	B
4>>(+<>==rBBB//!$$
7##%%'7888%%''gt,,,
3w<<QZ
j'222
:&&((,777
:l#5	7 	7 	7 	7 	7r;   c                 D   | j         }t          dd          5 }|                                }d d d            n# 1 swxY w Y   t                      }d|d<   d|d<   d|d	<   d
|_        d|_        t          d          }t          d          }|                    ddd           |                    |           |                    |           t                      }t          |          }|                    |            ||                                |           d S )N
msg_21.txtrV   r   rP  r   rQ  r   rM  r  MIME messagezEnd of MIME message
r  r  rD   rk   r   r3  )r  r&   r   r   rV  rW  r   rN  rn   r   r   r   r   )	r6   r7   r   r   r8   rm  r  r  r   s	            r9   test_epiloguezTestMIMEMessage.test_epilogue
  sD   "lW555 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	ii'F%D	I%.~'8:NNN

4

4jjcNN			#
3<<>>4        :>>c                 f   | j         }t                      }d|d<   d|d<   d|d<   d|_        d|_        t	          d	          }t	          d
          }|                    ddd           |                    |           |                    |            ||                                d           d S )NrP  r   rQ  r   rM  r  r  r+   r  r  rD   rk   r   r3  ad  From: aperson@dom.ain
To: bperson@dom.ain
Subject: Test
Content-Type: multipart/mixed; boundary="BOUNDARY"

MIME message
--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

One
--BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

Two
--BOUNDARY--
)r  r   rV  rW  r   rN  rn   r   )r6   r7   r8   rm  r  s        r9   test_no_nl_preamblez#TestMIMEMessage.test_no_nl_preamble1
  s    "ii'F%D	I%~'8:NNN

4

4
3==??  	 	 	 	 	r;   c                    | j         }t          dd          5 }t          j        |          }d d d            n# 1 swxY w Y   |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            ||                                d           d S )Nre  rV   r   r   ra  r   r?   r2   r&   r   message_from_filerZ   get_default_typerH   r6   r7   r   r8   
container1
container2container1acontainer2as           r9   test_default_typez!TestMIMEMessage.test_default_typeT
     lW555 	.)"--C	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.__Q''

:&&((*:;;;
:&&((*:;;;__Q''

:&&((*:;;;
:&&((*:;;; ,,Q//
;''))<888
;''))<888 ,,Q//
;''))<888
;''))<88888r  c                    | j         }t          dd          5 }t          j        |          }d d d            n# 1 swxY w Y   |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            ||                                d           |                    d          } ||                                d            ||                                d           d S )Nrj  rV   r   r   ra  r   r?   r  r  s           r9   .test_default_type_with_explicit_container_typez>TestMIMEMessage.test_default_type_with_explicit_container_typee
  r%  r  c                    | j         }| j        }t          dd          }d|_        t	          d          }t	          d          }t          |          }t          |          }|                    |           |                    |            ||                                d            ||                                d            ||                                d            ||                                d            ||	                    d          d           |d	= |d
= |d	= |d
=  ||                                d            ||                                d            ||                                d            ||                                d            ||	                    d          d           d S )Ndigestr   r+   
message 1

message 2
ra  r   a  Content-Type: multipart/digest; boundary="BOUNDARY"
MIME-Version: 1.0

--BOUNDARY
Content-Type: message/rfc822
MIME-Version: 1.0

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 1

--BOUNDARY
Content-Type: message/rfc822
MIME-Version: 1.0

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 2

--BOUNDARY--
r@   r>   aB  Content-Type: multipart/digest; boundary="BOUNDARY"
MIME-Version: 1.0

--BOUNDARY

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 1

--BOUNDARY

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

message 2

--BOUNDARY--
)
r2   r  r   rW  r   r   rn   rH   r  r   )r6   r7   r  r?  	subpart1a	subpart2asubpart1subpart2s           r9   test_default_type_non_parsedz,TestMIMEMessage.test_default_type_non_parsedv
  s   #!(J77		]++	]++	y))y))""""""
8$$&&(8999
8$$&&(8999
8$$&&(8999
8$$&&(8999I"" % 	 	 	4 ^$^$^$^$
8$$&&(8999
8$$&&(8999
8$$&&(8999
8$$&&(8999I"" % 	 	 	 	 	r;   c                 F   | j         }t          d          }t          d          }t          ||f          } |t          |                                          d            ||                    d          |            ||                    d          |           d S )Nr+   )	_subpartsr   r   r   )r2   r   r   r  rZ   )r6   r7   text1text2r8   s        r9   $test_mime_attachments_in_constructorz4TestMIMEMessage.test_mime_attachments_in_constructor
  s    uen555
3s  !!1%%%
3??1u%%%
3??1u%%%%%r;   c                 p    t                      }|                     |                                           d S rf   )r   r   r  rh   s     r9   "test_default_multipart_constructorz2TestMIMEMessage.test_default_multipart_constructor
  s/    oo((**+++++r;   c                     t                      }d|d<   d|d<   |                     |                    d          ddg           d S )Na@b.comr   c@d.comr   )r   r2   r4   rh   s     r9   test_multipart_default_policyz-TestMIMEMessage.test_multipart_default_policy
  sJ    ooD	D	T**Y	,BCCCCCr;   c                    t          t          j        j                  }d|d<   |                     t
                    5 }d|d<   d d d            n# 1 swxY w Y   |                     t          |j                  d           d S )Nr   r9  r   r:  z.There may be at most 1 To headers in a message)	r   r   r   r  r   rX  r2   r   	exception)r6   r8   cms      r9   test_multipart_custom_policyz,TestMIMEMessage.test_multipart_custom_policy
  s    5<#7888D	z** 	"b!CI	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"R\**I	K 	K 	K 	K 	Ks   AAAN)r  r  r  r  r  r  r  r  r	  r  r  r  r$  r'  r0  r5  r7  r;  r?  r{   r;   r9   r  r  	  s       # # #D D D( ( (K K K  (
G 
G 
G77 77 77r! ! !(! ! !F9 9 9"9 9 9"H H HT& & &, , ,D D DK K K K Kr;   r  c                       e Zd Zd Zd ZdS )TestNonMultipartc                 t    t          dd          }|                     |                                           d S )Nr   r  )r   r  r  rh   s     r9   "test_nonmultipart_is_not_multipartz3TestNonMultipart.test_nonmultipart_is_not_multipart
  s7    vw//))++,,,,,r;   c                     t                      }d|d<   t          dd          }|                     t          j        |j        |           d S )Nr   r  r   r  )r   r   r   r    r  rn   )r6   r8   r  s      r9   test_attach_raises_exceptionz-TestNonMultipart.test_attach_raises_exception
  sF    ii$IVW--&918SIIIIIr;   N)r  r  r  rC  rE  r{   r;   r9   rA  rA  
  s7        - - -J J J J Jr;   rA  c                       e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestIdempotentr*   c                     t          |d          5 }|                                }d d d            n# 1 swxY w Y   t          j        |          }||fS NrV   r   r&   r   r   r  r6   rK  r   r\   r8   s        r9   r3   zTestIdempotent._msgobj
  s    h111 	R7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'--Dyr   Fc                     | j         }t                      }t          |d          }|                    ||            |||                                           d S )Nr   r{  r   )r  r   r   r   r   )r6   r8   r   r   r7   r   r   s          r9   _idempotentzTestIdempotent._idempotent
  s[    "JJaa(((			#	)))
4r;   c                    | j         }|                     d          \  }} ||                                d            ||                                d            ||                                d            ||                                d         d            ||                    d          d            ||j        d             ||j        d            | 	                    ||           d S )	Nr   r?   r   r  r   )rA   rN   rA   rN   )
r2   r3   rH   rt  r  r  rI   rV  rW  rM  r6   r7   r8   r   s       r9   test_parse_text_messagez&TestIdempotent.test_parse_text_message
  s    LL..	T
3!!<000
3##%%v...
3""$$g...
3>>A 7888
3==##Z000
3<
3<d#####r;   c                 &   | j         }|                     d          \  }} ||                                d            ||                                d             ||                    d          d            |                     ||           d S )Nr   r?   rA   )r2   r3   rH   r  rI   rM  rO  s       r9   test_parse_untyped_messagez)TestIdempotent.test_parse_untyped_message  s    LL..	T
3!!<000
3>>T"""
3==##T***d#####r;   c                 b    |                      d          \  }}|                     ||           d S )Nry   r3   rM  r6   r8   r   s      r9   test_simple_multipartz$TestIdempotent.test_simple_multipart  3    LL..	Td#####r;   c                 b    |                      d          \  }}|                     ||           d S )N
msg_02.txtrT  rU  s      r9   test_MIME_digestzTestIdempotent.test_MIME_digest  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nz
msg_27.txtrT  rU  s      r9   test_long_headerzTestIdempotent.test_long_header  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nrj  rT  rU  s      r9   "test_MIME_digest_with_part_headersz1TestIdempotent.test_MIME_digest_with_part_headers  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )N
msg_06.txtrT  rU  s      r9   test_mixed_with_imagez$TestIdempotent.test_mixed_with_image#  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nr<  rT  rU  s      r9   test_multipart_reportz$TestIdempotent.test_multipart_report'  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nr  rT  rU  s      r9   r  zTestIdempotent.test_dsn+  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nr  rT  rU  s      r9   test_preamble_epiloguez%TestIdempotent.test_preamble_epilogue/  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nz
msg_23.txtrT  rU  s      r9   test_multipart_one_partz&TestIdempotent.test_multipart_one_part3  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nz
msg_24.txtrT  rU  s      r9   test_multipart_no_partsz&TestIdempotent.test_multipart_no_parts7  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nr  rT  rU  s      r9   r  z%TestIdempotent.test_no_start_boundary;  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )N
msg_32.txtrT  rU  s      r9   test_rfc2231_charsetz#TestIdempotent.test_rfc2231_charset?  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nz
msg_33.txtrT  rU  s      r9   test_more_rfc2231_parametersz+TestIdempotent.test_more_rfc2231_parametersC  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nz
msg_34.txtrT  rU  s      r9   %test_text_plain_in_a_multipart_digestz4TestIdempotent.test_text_plain_in_a_multipart_digestG  rW  r;   c                 b    |                      d          \  }}|                     ||           d S )Nzmsg_12a.txtrT  rU  s      r9   test_nested_multipart_mixedsz+TestIdempotent.test_nested_multipart_mixedsK  s3    LL//	Td#####r;   c                 b    |                      d          \  }}|                     ||           d S )Nrl  rT  rU  s      r9   %test_message_external_body_idempotentz4TestIdempotent.test_message_external_body_idempotentO  rW  r;   c                 f    |                      d          \  }}|                     ||d           d S )N
msg_43.txtTr   rT  rU  s      r9   test_message_delivery_statusz+TestIdempotent.test_message_delivery_statusS  s8    LL..	TdT22222r;   c                 b    |                      d          \  }}|                     ||           d S N
msg_45.txtrT  rU  s      r9   test_message_signed_idempotentz-TestIdempotent.test_message_signed_idempotentW  rW  r;   c                    | j         }|                     d          \  }} ||                                d           i }|                                D ]
\  }}|||<    ||d         d            ||d         d            ||j        d| j        z               ||j        | j                    |t          |                                          d           |                    d	          } ||                                d
            ||                                d| j        z              |                    d          } ||                                d
            ||                                d| j        z              |                    d          }	 ||	                                d           | 	                    |	t                     |	                                }
| 	                    |
t                      |t          |
          d           |
d	         }| 	                    |t                      ||                                d| j        z              d S )Nr<  r>  r?  r@  r  rB  z$This is a MIME-encapsulated message.r   r   r?   zYadda yadda yaddar   r   ra  )r2   r3   rH   r  rV  r   rW  r  rZ   r  r   r  )r6   r7   r8   r   paramspkpvrm  r  msg3r  msg4s               r9   test_content_typez TestIdempotent.test_content_type[  sk   LL..	T
3!!#5666nn&& 	 	FBF2JJ
6- "3444
6*FGGG
3<?$,NOOO
3<&&&
3s  !!1%%%q!!
4  ""L111
42T\ABBBq!!
4  ""L111
42T\ABBBq!!
4  ""$4555dG,,,""$$gt,,,
3w<<qzdG,,,
42T\ABBBBBr;   c                 2   | j         }|                     d          \  }} ||                                d           |                                }|                     |t
                      |t          |          d           |d         }|                     |t                      ||                                d           |                     |                                t                      ||                                | j	                   d S )Nr`  ra  r   r   r?   )
r2   r3   rH   rZ   r  r  r  r   r   r   )r6   r7   r8   r   r  rm  s         r9   test_parserzTestIdempotent.test_parserz  s   LL..	T
3!!#3444 //##gt,,,
3w<<qzdG,,,
4  ""L111d..00#666
4t|,,,,,r;   NF)r  r  r  r   r3   rM  rP  rR  rV  rZ  r\  r^  ra  rc  r  rf  rh  rj  r  rn  rp  rr  rt  rv  ry  r}  r  r  r{   r;   r9   rG  rG  
  s       G     
$ 
$ 
$$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $$ $ $3 3 3$ $ $C C C>- - - - -r;   rG  c                   |   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+ e,j-                    d*             Z.d+ Z/d, Z0d- Z1d. Z2d/ Z3d0 Z4d1 Z5d2 Z6d3 Z7d4 Z8d5 Z9d6 Z:d7S )8TestMiscellaneousc                 `   t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          j        |          }t	                      }t          |d          }|                    |           |                     ||                                           d S Nr   rV   r   r   r{  	r&   r   r   r  r   r   r   r2   r   r6   r   r   r8   r   r   s         r9   test_message_from_stringz*TestMiscellaneous.test_message_from_string  s    lW555 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'--JJ aa(((			#qzz||,,,,,r   c                    t          dd          5 }|                                }|                    d           t          j        |          }t                      }t          |d          }|                    |           |                     ||	                                           d d d            d S # 1 swxY w Y   d S r  )
r&   r   seekr   r  r   r   r   r2   r   r  s         r9   test_message_from_filez(TestMiscellaneous.test_message_from_file  s    lW555 		17799DGGAJJJ)"--C

A !!,,,AIIcNNNT1::<<000		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1 		1s   BB99B= B=c                    t          dd          5 }|                                }d d d            n# 1 swxY w Y    G d dt                    }t          j        ||          }|                     ||           t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          j        ||          }|                                D ]}|                     ||           d S )Nr   rV   r   c                       e Zd ZdS )HTestMiscellaneous.test_message_from_string_with_class.<locals>.MyMessageNr  r  r  r{   r;   r9   	MyMessager            Dr;   r  rY  )r&   r   r   r   r  r  walk)r6   r   r   r  r8   r   s         r9   #test_message_from_string_with_classz5TestMiscellaneous.test_message_from_string_with_class  s   lW555 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 'i88c9---lW555 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'i88xxzz 	6 	6G!!'95555	6 	6s   377B..B25B2c                     G d dt                     }t          dd          5 }t          j        ||          }d d d            n# 1 swxY w Y   |                     ||           t          dd          5 }t          j        ||          }d d d            n# 1 swxY w Y   |                                D ]}|                     ||           d S )Nc                       e Zd ZdS )FTestMiscellaneous.test_message_from_file_with_class.<locals>.MyMessageNr  r{   r;   r9   r  r    r  r;   r  r   rV   r   rY  )r   r&   r   r  r  r  )r6   r  r   r8   r   s        r9   !test_message_from_file_with_classz3TestMiscellaneous.test_message_from_file_with_class  sl   	 	 	 	 	 	 	 	 lW555 	9)"i88C	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9c9---lW555 	9)"i88C	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9xxzz 	6 	6G!!'95555	6 	6s#   AAA9BB"Bc                      G d dt                     }|                     d|          }|                     ||           d S )Nc                        e Zd Z fdZ xZS )STestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessagec                 H    t                                                       d S rf   )super__init__)r6   	__class__s    r9   r  z\TestMiscellaneous.test_custom_message_does_not_require_arguments.<locals>.MyMessage.__init__  s      """""r;   )r  r  r  r  __classcell__)r  s   @r9   r  r    s8        # # # # # # # # #r;   r  zSubject: test

test)r   r  r  )r6   r  r8   s      r9   .test_custom_message_does_not_require_argumentsz@TestMiscellaneous.test_custom_message_does_not_require_arguments  s^    	# 	# 	# 	# 	# 	# 	# 	# mm3Y??c9-----r;   c                 x    t          d          }|                     t          |j                  g d           d S )Nr   )r   rA   r   r    
feedparserr   r   r!   rw  message_from_binary_filer   r  r  r  r   r"   r#   )
__import__r2   sorted__all__)r6   modules     r9   test__all__zTestMiscellaneous.test__all__  sL    G$$// 2 2 2 	 	 	 	 	r;   c                     t          j                     }|                     t          j        t          j        |                    d d         t          j        |          d d                    d S )N   )r9  r2   r#   	parsedate
formatdategmtimer6   rA  s     r9   test_formatdatez!TestMiscellaneous.test_formatdate  se    ikk)9#)>)>??CS))"1"-	/ 	/ 	/ 	/ 	/r;   c                     t          j                     }|                     t          j        t          j        |d                    d d         t          j        |          d d                    d S )NTr:  r  )r9  r2   r#   r  r  r:  r  s     r9   test_formatdate_localtimez+TestMiscellaneous.test_formatdate_localtime  sk    ikkOE,SDAAABB2A2FN3#	% 	% 	% 	% 	%r;   c           	      j   t          j                     }|                     t          j        |d          t          j        dt          j        |                               |                     t          j        |dd          t          j        dt          j        |                               d S )NFr  z%a, %d %b %Y %H:%M:%S -0000T)r:  usegmtz%a, %d %b %Y %H:%M:%S GMT)r9  r2   r#   r  r=  r  r  s     r9   test_formatdate_usegmtz(TestMiscellaneous.test_formatdate_usegmt  s    ikkSE222M7S9I9IJJ	L 	L 	L 	SE$???M5t{37G7GHH	J 	J 	J 	J 	Jr;   c                    g d}|D ]~}|                      |          5  |                     t          j        |                     |                     t          j        |                     d d d            n# 1 swxY w Y   |                     t          j        d                      |                     t          j        d                      d S )N)	r+   r,   0zA Complete Waste of Timez Wed, 3 Apr 2002 12.34.56.78+0800z17 June , 2022zFriday, -Nov-82 16:14:55 ESTzFriday, Nov--82 16:14:55 ESTzFriday, 19-Nov- 16:14:55 EST)dtstr)subTestr  r#   r  parsedate_tz)r6   invalid_datesr  s      r9   /test_parsedate_returns_None_for_invalid_stringszATestMiscellaneous.test_parsedate_returns_None_for_invalid_strings  s   

 

 

 # 	= 	=EE** = =!!%/%"8"8999!!%"4U";";<<<= = = = = = = = = = = = = = = 	%/$//000%,T2233333s   AA::A>	A>	c                     |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           d S )NzWed, 3 Apr 2002 14:58:26 +0800
  r   r      :      r   r   r4  p  zWed,3 Apr 2002 14:58:26 +0800zWed 3 Apr 2002 14:58:26 +0800r2   r#   r  r  s    r9   test_parsedate_compactz(TestMiscellaneous.test_parsedate_compact   s    +,LMMB	D 	D 	D 	+,KLLB	D 	D 	D 	+,KLLB	D 	D 	D 	D 	Dr;   c                     | j         } |t          j        d          d            |t          j        d          d           d S )N5 Feb 2003 13:47:26 -0800
  r         /   r  r   r   r4  透zFebruary 5, 2003 13:47:26 -0800r  r6   r7   s     r9   test_parsedate_no_dayofweekz-TestMiscellaneous.test_parsedate_no_dayofweek
  s^    
59::5	7 	7 	7
5?@@5	7 	7 	7 	7 	7r;   c                 V    |                      t          j        d          d           d S )NzWed, 3 Apr 2002 14:58:26+0800r  r  r  s    r9   .test_parsedate_no_space_before_positive_offsetz@TestMiscellaneous.test_parsedate_no_space_before_positive_offset  s5    +,KLL4	6 	6 	6 	6 	6r;   c                 V    |                      t          j        d          d           d S )NzWed, 3 Apr 2002 14:58:26-0800)
r  r   r   r  r  r  r   r   r4  r  r  r  s    r9   .test_parsedate_no_space_before_negative_offsetz@TestMiscellaneous.test_parsedate_no_space_before_negative_offset  s5    +,KLL5	7 	7 	7 	7 	7r;   c                     | j         } |t          j        d          d            |t          j        d          d           d S )Nz5 Feb 2003 13.47.26 -0800r  z5 Feb 2003 13.47 -0800)
r  r   r  r  r  r   r   r   r4  r  r  r  s     r9   %test_parsedate_accepts_time_with_dotsz7TestMiscellaneous.test_parsedate_accepts_time_with_dots  s^    
59::5	7 	7 	7
56774	6 	6 	6 	6 	6r;   c                 V    |                      t          j        d          d           d S )NzFriday, 19-Nov-82 16:14:55 EST)
i           r  7   r   r   r4  ir  r  s    r9   test_parsedate_rfc_850z(TestMiscellaneous.test_parsedate_rfc_850!  s5    +,LMM7	9 	9 	9 	9 	9r;   c                 V    |                      t          j        d          d           d S )NzWed, 3 Apr 2002 14:58 +0800
r  r   r   r  r  r   r   r   r4  r  r  r  s    r9   test_parsedate_no_secondsz+TestMiscellaneous.test_parsedate_no_seconds%  s:    +,IJJA	C 	C 	C 	C 	Cr;   c                     |                      t          j        d          d           |                      t          j        d          d           d S )NzWed, 3 Apr 2002 14.58.26 +0800r  zWed, 3 Apr 2002 14.58 +0800r  r  r  s    r9   !test_parsedate_dot_time_delimiterz3TestMiscellaneous.test_parsedate_dot_time_delimiter)  sf    +,LMMB	D 	D 	D+,IJJA	C 	C 	C 	C 	Cr;   c           
      p   | j         }t          j        d          }t          t	          j        |                    } |t	          j        |          d d         |d d                     |t          t	          j        d|                    d           t          j        d          }t          t	          j        |d d                             } |t	          j        |          d d         |d d                     |t          t	          j        d|d d                             d           d S )Nr  r  z%Yr  	   )	r2   r#   r  intr9  mktimer:  r=  r  )r6   r7   timetupr  s       r9   +test_parsedate_acceptable_to_time_functionsz=TestMiscellaneous.test_parsedate_acceptable_to_time_functions/  s   /"=>>G$$%%
4>!RaR '"1"+...
3t}T7++,,d333$%@AAGBQBK(())
4>!RaR '"1"+...
3t}T72A2;//00$77777r;   c                     |                      t          j        d          d           |                      t          j        d          d           d S )N)
  r   r   r   r   r   r4  r4  r4  r   r   )
r  r   r   r   r   r   r4  r4  r4  i  i.)r2   r#   	mktime_tzr  s    r9   test_mktime_tzz TestMiscellaneous.test_mktime_tz:  sm     *9 : :;<	> 	> 	> *< = =>C	E 	E 	E 	E 	Er;   c                     |                      t          j        d          t          j        d                     |                      t          j        d          t          j        d                     dS )a   Test for parsing a date with a two-digit year.

        Parsing a date with a two-digit year should return the correct
        four-digit year. RFC822 allows two-digit years, but RFC2822 (which
        obsoletes RFC822) requires four-digit years.

        z25 Feb 03 13:47:26 -0800z25 Feb 2003 13:47:26 -0800z25 Feb 71 13:47:26 -0800z25 Feb 1971 13:47:26 -0800Nr  r  s    r9   test_parsedate_y2kz$TestMiscellaneous.test_parsedate_y2k@  s     	+,FGG+,HII	K 	K 	K+,FGG+,HII	K 	K 	K 	K 	Kr;   c                     |                      t          j        d          d           |                      t          j        t          j        d                    d           d S )Nz<>r+   r+   r+   r2   r#   	parseaddr
formataddrr  s    r9   test_parseaddr_emptyz&TestMiscellaneous.test_parseaddr_emptyM  sS    ..999)%/$*?*?@@"EEEEEr;   c                     |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           d S )Nza@b@cr  za@b.c@cza@172.17.0.1@cr2   r#   r  r  s    r9   test_parseaddr_multiple_domainsz1TestMiscellaneous.test_parseaddr_multiple_domainsQ  s    OG$$	
 	
 	
 	OI&&	
 	
 	
 	O,--	
 	
 	
 	
 	
r;   c                 V    |                      t          j        d          d           d S )N)zA Silly Personperson@dom.ainzA Silly Person <person@dom.ain>r2   r#   r  r  s    r9   test_noquote_dumpz#TestMiscellaneous.test_noquote_dump_  s6    ABB-	/ 	/ 	/ 	/ 	/r;   c                 *   |                      t          j        d          d           |                      t          j        d          d           d}d}|                      t          j        t          j        ||f                    ||f           d S )N)zA (Very) Silly Personr  z("A (Very) Silly Person" <person@dom.ain>z*"A \(Very\) Silly Person" <person@dom.ain>zA \(Special\) Personr  r2   r#   r  r  r6   r  r  s      r9   test_escape_dumpz"TestMiscellaneous.test_escape_dumpd  s    HII7	9 	9 	9 	OIJJ7	9 	9 	9 $)91a&)A)ABBQFKKKKKr;   c                     |                      t          j        d          d           d}d}|                      t          j        t          j        ||f                    ||f           d S )N)Arthur \Backslash\ Foobarr  z."Arthur \\Backslash\\ Foobar" <person@dom.ain>r  r  r  r  s      r9   test_escape_backslashesz)TestMiscellaneous.test_escape_backslasheso  sq    MNN=	? 	? 	? ))91a&)A)ABBQFKKKKKr;   c                     d}d}d}d}|                      t          j        ||f          |           |                      t          j        ||fd          |           d S )N   Häns Würstr  -=?utf-8?b?SMOkbnMgV8O8cnN0?= <person@dom.ain>z0=?iso-8859-1?q?H=E4ns_W=FCrst?= <person@dom.ain>r=   r  )r6   r&  addrutf8_base64latin1_quopris        r9   test_quotes_unicode_namesz+TestMiscellaneous.test_quotes_unicode_namesw  ss    %EJ)4,77EEE)4,EE	 	 	 	 	r;   c                     d}d}d}d G fdd          } |            }d|d}|                      t          j        ||f|          |           |                      t          j        ||ft          d	                    |           d S )
Nr  r  r	  FOOBARc                       e Zd Z fdZdS )KTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMockc                     S rf   r{   )r6   stringrT  s     r9   header_encodezYTestMiscellaneous.test_accepts_any_charset_like_object.<locals>.CharsetMock.header_encode  s    r;   N)r  r  r  r  )rT  s   r9   CharsetMockr    s.              r;   r  z <>rV   )r2   r#   r  r
   )r6   r&  r
  r  r  mockmock_expectedrT  s          @r9   $test_accepts_any_charset_like_objectz6TestMiscellaneous.test_accepts_any_charset_like_object  s    %E	 	 	 	 	 	 	 	 	 	 {}}%+VVTTT2)4,==}MMM)4,8H8HII	 	 	 	 	r;   c                 |    d}d}t                      }|                     t          t          j        ||f|           d S )Nr  r  )objectr   AttributeErrorr#   r  )r6   r&  r
  bad_charsets       r9   -test_invalid_charset_like_object_raises_errorz?TestMiscellaneous.test_invalid_charset_like_object_raises_error  sG    %hh.%*:T4L	 	 	 	 	r;   c                     d}|                      t          t          j        d |f           |                      t          t          j        d|f           d S )Nu   persön@dom.inName)r   UnicodeErrorr#   r  )r6   r
  s     r9   !test_unicode_address_raises_errorz3TestMiscellaneous.test_unicode_address_raises_error  sK    #,(84,GGG,(864.IIIIIr;   c                    d}d}d\  }}|                      t          j        |          ||f           |                      t          j        |          ||f           |                      t          j        ||f          |           d S )NzJohn X. Doe <jxd@example.com>z"John X. Doe" <jxd@example.com>)zJohn X. Doezjxd@example.comr  )r6   r  yr  r  s        r9   test_name_with_dotz$TestMiscellaneous.test_name_with_dot  s    +-11++aV444++aV444)1a&11155555r;   c                     | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d           d S )N""example" example"@example.com)r+   r'  !"\"example\" example"@example.com)r+   r(  #"\\"example\\" example"@example.com)r+   r)  r  r  s     r9   2test_parseaddr_preserves_quoted_pairs_in_addresseszDTestMiscellaneous.test_parseaddr_preserves_quoted_pairs_in_addresses  s     
5?<==
1	3 	3 	3
5?@AA
5	7 	7 	7
5?DEE
9	; 	; 	; 	; 	;r;   c                    |                      dt          j        d                     |                      dt          j        d                     |                      dt          j        d                     |                      dt          j        d                     |                      dt          j        d	                     d S )
N)r+   merwok wok@xample.comr,  )r+   merwok  wok@xample.comr-  z merwok  wok  @xample.com)r+   merwok"wok"  wok@xample.comr.  )r+   zmerwok.wok.wok@xample.comzmerwok. wok .  wok@xample.comr  r  s    r9   -test_parseaddr_preserves_spaces_in_local_partz?TestMiscellaneous.test_parseaddr_preserves_spaces_in_local_part  s     	6O344	6 	6 	67O455	7 	7 	77O788	: 	: 	:<O9::	< 	< 	<:O;<<	> 	> 	> 	> 	>r;   c                     d}d}|                      t          j        |          |           |                      t          j        |          |           d S )N)z#'foo@example.com' (foo@example.com)foo@example.comz7"'foo@example.com' (foo@example.com)" <foo@example.com>r  )r6   r
  addrstrs      r9   6test_formataddr_does_not_quote_parens_in_quoted_stringzHTestMiscellaneous.test_formataddr_does_not_quote_parens_in_quoted_string  sX    #C114888)$//99999r;   c                 Z    d}|                      t          j        |          d           d S )NzFoo
	Bar <foo@example.com>)zFoo Barr1  r  )r6   r  s     r9   test_multiline_from_commentz-TestMiscellaneous.test_multiline_from_comment  s2     	++-KLLLLLr;   c                 V    |                      t          j        d          d           d S )N)zA Silly; Personr  z""A Silly; Person" <person@dom.ain>r  r  s    r9   test_quote_dumpz!TestMiscellaneous.test_quote_dump  s6    BCC1	3 	3 	3 	3 	3r;   c                    | j         }| j        }t                      }t                      } ||d            ||d            ||d            |d|            |d|            |d|            ||d            ||d            ||d            |d|            |d|            |d|            |||            |||           d S )NrN   US-ASCIIzUs-AsCiIusasciiUSASCIIUsAsCiI)r2   assertNotEqualr
   )r6   r7   necset1cset2s        r9   test_charset_richcomparisonsz.TestMiscellaneous.test_charset_richcomparisons  s&    				
5*
5*
5*
:u
:u
:u
5)
5)
5)
9e
9e
9e
5%
5%r;   c                 X    | j         } |t          j        ddg          ddg           d S )Nzaperson@dom.ain (Al Person)zBud Person <bperson@dom.ain>)z	Al PersonrP  )z
Bud PersonrQ  r2   r#   getaddressesr  s     r9   test_getaddressesz#TestMiscellaneous.test_getaddresses  sO    
5<=? @ @,-/	0 	0 	0 	0 	0r;   c                     | j         } |t          j        dg          dg            |t          j        dg          g d            |t          j        ddg          ddg           d S )Nzfoo: ;r  z	[]*-- =~$)r  r  )r+   z*--z#"Jason R. Mastaler" <jason@dom.ain>)zJason R. Mastalerzjason@dom.ainrC  r  s     r9   test_getaddresses_nastyz)TestMiscellaneous.test_getaddresses_nasty  s    
5xj))H:666
5= ,,,	. 	. 	. 	5;<> ><=	? 	? 	? 	? 	?r;   c                 n    | j         }t          j        dg          } ||d         d         d           dS )z(Test proper handling of a nested commentz%User ((nested comment)) <foo@bar.com>r   r   foo@bar.comNrC  )r6   r7   addrss      r9   "test_getaddresses_embedded_commentz4TestMiscellaneous.test_getaddresses_embedded_comment  s>    "$K#LMM
58A;&&&&&r;   c                     t          j        t          d          g          }|                     |d         d         d           dS )z%Test the handling of a Header object.zAl Person <aperson@dom.ain>r   r   rP  N)r#   rD  r   r2   )r6   rJ  s     r9   test_getaddresses_header_objz.TestMiscellaneous.test_getaddresses_header_obj  sC    "F+H$I$I#JKKq!&788888r;   c                 l    G d dt                     fdt          d          D             }t          j        |          5  	 d d d            n# 1 swxY w Y   t	          d |D             g           }|                     t          t          |                    t          |                     d S )Nc                       e Zd Zd ZdS )BTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThreadc                     g | _         | j         j        }t          j        }t          j        } |            dz   } |            |k     r% | |d                      |            |k     #d S d S )Ng      @testdomain-stringdomain)msgidsr(  r#   
make_msgidr9  	monotonic)r6   r(  rV  clocktfins        r9   runzFTestMiscellaneous.test_make_msgid_collisions.<locals>.MsgidsThread.run  sw     +"-
uww}eggnnF::-@AAABBB eggnnnnnnr;   N)r  r  r  rZ  r{   r;   r9   MsgidsThreadrP    s(        C C C C Cr;   r[  c                 $    g | ]}             S r{   r{   )r   rI  r[  s     r9   r   z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>  s    444a<<>>444r;   r  c                     g | ]	}|j         
S r{   )rU  )r   r  s     r9   r   z@TestMiscellaneous.test_make_msgid_collisions.<locals>.<listcomp>!  s    111Aqx111r;   )r   rO  r$   start_threadssumr2   r  set)r6   threadsall_idsr[  s      @r9   test_make_msgid_collisionsz,TestMiscellaneous.test_make_msgid_collisions  s   		C 		C 		C 		C 		C6 		C 		C 		C 5444588444+G44 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	11111266S\\**CLL99999s   AAAc                     | j         }t                      }|                    ddd            ||                                d           d S )NrL  rH  zfoo\wacky"namerJ  )r2   r   rN  r}   r5   s      r9   test_utils_quote_unquotez*TestMiscellaneous.test_utils_quote_unquote$  s[    ii,l 1 	 	3 	3 	3
3011111r;   c                 t    t          d          }|                     |                                d           d S )Nznot a charsetrW   r
   r2   get_body_encodingr6   rA   s     r9   )test_get_body_encoding_with_bogus_charsetz;TestMiscellaneous.test_get_body_encoding_with_bogus_charset+  s7    /**2244h?????r;   c                    | j         }t                      }d|d<    ||d         d           |                                } |t          |          d            ||d         d           t	          |d                   } ||                                d           |                    d|	            ||                                d
            ||                    d          d            ||d         d           t                      }d|d<   |                                } |t          |          d            ||d         d           t	          |d                   } ||                                t          j	                   |                    d|	            ||                                d            ||d         d           d S )Nztext/plain; charset=UTF-8rD   r@   r   r   rV   rW   r   rS  aGVsbG8gd29ybGQ=
TrX   rB   ztext/plain; charset="US-ASCII"rN   r  r  )
r2   r   ru   r  r
   rh  rR   rZ   r   r  )r6   r7   r8   rv   rA   s        r9   -test_get_body_encoding_with_uppercase_charsetz?TestMiscellaneous.test_get_body_encoding_with_uppercase_charset/  s   ii9N
3~ ;<<<##%%
3x==!
8A;   (1+&&
7$$&&111888
3??2333
3??$?''888
3*+X666ii>N##%%
3x==!
8A;
###(1+&&
7$$&&(?@@@w777
3??m,,,
3*+V44444r;   c                     t          d          }t          d          }|                     |                                |                                           d S )NrN   r9  rg  )r6   lcucs      r9   test_charsets_case_insensitivez0TestMiscellaneous.test_charsets_case_insensitiveI  sP    Z  Z  --//1E1E1G1GHHHHHr;   c                     | j         }|                     d          }t                      }t          j        ||            ||                                d           d S )Nrx  aB  multipart/report
    text/plain
    message/delivery-status
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
        text/plain
    text/rfc822-headers
rs  ru  s       r9   1test_partial_falls_inside_message_delivery_statuszCTestMiscellaneous.test_partial_falls_inside_message_delivery_statusN  sf    "
 ll<((jjS#&&&
3<<>>  	 	 	 	 	r;   c                 ~    |                      t          j                            d          dd          d           d S )NrR  rS  iz@testdomain-string>r2   r   r#   rV  r  s    r9   test_make_msgid_domainz(TestMiscellaneous.test_make_msgid_domainx  sG    K""*=">>sttD!	# 	# 	# 	# 	#r;   c                     |                      t          j                            dd          dd          d           d S )Nztest-idstringrR  )idstringrT  iz!.test-idstring@testdomain-string>ru  r  s    r9   test_make_msgid_idstringz*TestMiscellaneous.test_make_msgid_idstring}  sR    K""O* # , ,,/DD2/	1 	1 	1 	1 	1r;   c                     t          d          5 }dx|_        }|                     t          j                                                            d|z   dz                        d d d            d S # 1 swxY w Y   d S )Nzsocket.getfqdnzpythontest.example.com@r  )r	   return_valuer   r   r#   rV  endswith)r6   mock_getfqdnrT  s      r9   test_make_msgid_default_domainz0TestMiscellaneous.test_make_msgid_default_domain  s    #$$ 	)1IIL%OO&&((11&L3&( () ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   AA11A58A5c                    t          ddd          5 }|                                }d d d            n# 1 swxY w Y   |                    dd          }t          j        |          }t                      }t          j                            |          }|                    |           | 	                    |
                                |           d S )N
msg_26.txtrV   r*   r   newliner   )r&   r   r   r   r  r   r   r   r   r2   r   r6   fmsgtxt	msgtxt_nlr8   r   r   s          r9   test_Generator_linendz'TestMiscellaneous.test_Generator_linend  s    lWdCCC 	qVVXXF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	NN6400	'//JJO%%a((			#y11111   488c                    t          ddd          5 }|                                }d d d            n# 1 swxY w Y   |                    dd          }t          j        |          }t                      }t          j                            |          }|                    |d           | 	                    |
                                                    d          |           d S )Nr  rV   r*   r  r   r   r   )r&   r   r   r   r  r   r   r   r   r2   r   rY   r  s          r9   test_BytesGenerator_linendz,TestMiscellaneous.test_BytesGenerator_linend  s    lWdCCC 	qVVXXF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	NN6400	'	22IIO**1--			#v	&&&,,W55v>>>>>r  c                    t          dd          5 }|                                }d d d            n# 1 swxY w Y   |                    dd          }|                    dd          }t          j        |          }t                      }t          j                            |          }|                    |d           | 	                    |
                                |           d S )	Nr  r  s   with attachments   fo   
r   r   r   )r&   r   r   r   r   r   r   r   r   r2   r   r  s          r9   )test_BytesGenerator_linend_with_non_asciiz;TestMiscellaneous.test_BytesGenerator_linend_with_non_ascii  s    lD)) 	QVVXXF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 2I>>NN7E22	&y11IIO**1--			#v	&&&v.....r  c                 8   t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          dft          |fft          |fft
          t                      fft          dft          dfg}|D ]\  }}| 	                    |j
        d          5   || }|                     |j        t          j        j                   d d d            n# 1 swxY w Y   | 	                    |j
        d          5   ||d	t          j        j        i}|                     |j        t          j        j                   d d d            n# 1 swxY w Y   d S )
Nr  r  r  )r+   )r1  r2  r  )clsr   r  r   )r&   r   r   r   r   r   r   r   r   r  r  r  r   r   r  r  )r6   r   	audiodatar  classesr  constructorr   s           r9   !test_mime_classes_policy_argumentz3TestMiscellaneous.test_mime_classes_policy_argument  s|   k4(( 	"B		I	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"lD)) 	 RggiiG	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  e$%
#799,'56u
 !( 	> 	>C#,zBB ? ?C%ah(=>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #,yAA > >CBU\-ABBah(<===> > > > > > > > > > > > > > >		> 	>sC   266A..A25A20DD	 D	 AFF	F	N);r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r%  r*  r/  r3  r5  r7  rA  rE  rG  rK  rM  r$   requires_working_threadingrc  re  rj  rm  rq  rs  rv  ry  r  r  r  r  r  r{   r;   r9   r  r    s       	- 	- 	-
1 
1 
16 6 6"6 6 6. . .  / / /
% % %J J J4 4 4,D D D7 7 76 6 67 7 7
6 6 69 9 9C C CC C C	8 	8 	8E E EK K KF F F
 
 
/ / /
	L 	L 	LL L L      J J J6 6 6; ; ;$> > >$: : :M M M3 3 3
  (0 0 0? ? ?' ' '9 9 9
 1022: : 32:&2 2 2@ @ @5 5 54I I I
( ( (T# # #
1 1 1) ) )	2 	2 	2	? 	? 	?
/ 
/ 
/> > > > >r;   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestIteratorsc                    | j         }| j        }|                     d          }t          j        |          }t          |          } |t          |          d            |t                              |          |	                                           |                     d          }t          j        |          }t          |          } |t          |          d           t          dd          5 } |t                              |          |                                           d d d            d S # 1 swxY w Y   d S )Nr   r  rY  +   z
msg_19.txtrV   r   )r2   r  r3   r!   body_line_iteratorr  r  EMPTYSTRINGr   rZ   r&   r   )r6   r7   r  r8   itr   r   s          r9   test_body_line_iteratorz%TestIterators.test_body_line_iterator  s`   #ll<(()#..R
3u::qKU##S__%6%6777ll<(()#..R
3u::rlW555 	4C  ''333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   87D<<E E c                 2   | j         }|                     d          }t          j        |d          }g }d}|D ].}|dz  }|                    |                                           / ||d            |t                              |          d           d S )Nry   r   r   r   r   z`a simple kind of mirror
to reflect upon our own
a simple kind of mirror
to reflect upon our own
r2   r3   r!   typed_subpart_iteratorr(  rZ   r  r   r6   r7   r8   r  r   subpartsr   s          r9   test_typed_subpart_iteratorz)TestIterators.test_typed_subpart_iterator  s    ll<((-c6:: 	0 	0GMHLL,,..////
8Q
;E"" % 	 	 	 	 	r;   c                 4   | j         }|                     d          }t          j        |dd          }g }d}|D ].}|dz  }|                    |                                           / ||d            |t                              |          d           d S )Nr   r   r  r   r   z%
Hi,

Do you like this message?

-Me
r  r  s          r9   (test_typed_subpart_iterator_default_typez6TestIterators.test_typed_subpart_iterator_default_type  s    ll<((-c67CC 	0 	0GMHLL,,..////
8Q
;E"" % 	 	 	 	 	r;   c                    g d}ddl m}m}  |            }g }d}|D ]i\  }}|                    |           ||z  }d}	t	          |j        |          D ]}
|                    |
           |	dz  }	|                     ||	           j|                     t          |          |           |                     d	                    d |D                       d	                    |                     dS )zFeedParser 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.
        ))za 
r   )r  r   )zc
r   )r+   r   )zd
r   )zer   )z
fr   )r   r   r   BufferedSubFileNeedMoreDatar   r+   c                     g | ]\  }}|S r{   r{   )r   ilns      r9   r   z0TestIterators.test_pushCR_LF.<locals>.<listcomp>  s    !6!6!6Q"!6!6!6r;   N)
email.feedparserr  r  pushiterreadliner(  r2   r  r   )r6   imtr  r  bsfomntr  r  n1ols              r9   test_pushCR_LFzTestIterators.test_pushCR_LF  s    
	 	 	 	CBBBBBBBo 	$ 	$EBHHRLLL!GBB3<66  		"aQ####R"%%%!6!6#!6!6!677EEEEEr;   c                    ddl m}m} d}d}dd                    fdt	          |          D                       dz   }|                    d	          } |            }g }t	          dt          |          |          D ]L}	||	|	|z            }
|                    |
           |                    t          |j
        |                     M|                     ||           d S )
Nr   r  i'  r  zabcd 	
r+   c              3   6   K   | ]}t                    V  d S rf   r   )r   rI  charss     r9   rJ  z1TestIterators.test_push_random.<locals>.<genexpr>  s)      44aF5MM444444r;   r*   T)r  r  r  r   rO  r  r  r  extendr  r  r2   )r6   r  r  r  	chunksizer   targetr  r   rI  chunkr  s              @r9   test_push_randomzTestIterators.test_push_random  s    BBBBBBBB	GG444458844444t;d##oq#a&&),, 	; 	;Aa)m$EHHUOOOLLclL99::::'''''r;   N)r  r  r  r  r  r  r  r  r{   r;   r9   r  r    sb        4 4 4"  "  &F F F<( ( ( ( (r;   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestFeedParsersc                 z    t                      }|D ]}|                    |           |                                S rf   )r(   feedclose)r6   chunksr  r  s       r9   parsezTestFeedParsers.parse,  sA    \\
 	# 	#EOOE""""!!!r;   c                     |                      d          }|                     |d         d           |                     |d         d           d S )NzFirst: val
: bad
Second: valr  valr  )r  r2   rh   s     r9   test_empty_header_name_handledz.TestFeedParsers.test_empty_header_name_handled2  sN    jj9::Wu---X.....r;   c                    |                      dg          }|                     |                                g d           |                      dg          }|                     |                                g d           |                      ddg          }|                     |                                ddg           |                      dd	g          }|                     |                                dd
g           |                      ddg          }|                     |                                dd
g           |                      dg          }|                     |                                dg           |                      g d          }|                     |                                ddg           d S )Nza:
b:c:
d:
)r  r  cdza:
b:c:
d:za:bc:
r  bca:zb:
r  z
b:
u   a:b: c:
)r  u	   b: c:)r  u   b:r  r  r+   )r  u   c:)r  r2   r  r   r  s     r9   test_newlineszTestFeedParsers.test_newlines8  s   JJ,-..#7#7#7888JJ*+,,#7#7#7888JJ())C;///JJ'((C:...JJ)**C:... JJ,-..%<$=>>>JJ11122Y$@AAAAAr;   c                    d\  }}|                      dgd|z  g|z  z             }|                     |                                dg           |                     |                                d|z  |z             |                      dgd|z  g|z  z             }|                     |                                dg           |                     |                                d|z  |z             |                      dgd|z  dz   g|z  z             }|                     |                                dg           |                     |                                d|z  dz   |z             |                      ddgd|z  g|z  z             }|                     |                                d	d
d|z  |z  fg           d S )N)i  i N  za:b

r  )r  r  za:b   r  zb: r  r  )r  r2   r   rZ   )r6   MNr   s       r9   test_long_lineszTestFeedParsers.test_long_linesJ  s   1JJ	{c!eWq[011ZL111#a%'222JJ	{c!eWq[011ZL111#a%'222JJ	{c!eFl^a%7788ZL1113q5<*:;;;JJ#a%1455Yc!eAg$?@@@@@r;   N)r  r  r  r  r  r  r  r{   r;   r9   r  r  *  sX        " " "/ / /B B B$A A A A Ar;   r  c                   ~    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdZd Zd Zd Zd Zd Zd Zd ZdS )TestParsersc                    | j         }t          dd          5 }t                                          |          }d d d            n# 1 swxY w Y    ||d         d            ||d         d            ||                                d           |                     |                                           |                     |                                t                     d S )	NrY  rV   r   r   ppp-request@zzz.orgr   ppp@zzz.orgrk   )
r2   r&   r   r  rH   r  r  r  rZ   r   r6   r7   r   r8   s       r9   test_header_parserzTestParsers.test_header_parser\  s   lW555 	+..&&r**C	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+
3v;-...
3t9m$$$
3!!#4555))++,,,coo//55555s   "AAAc                 P   | j         }t          dd          5 }t          j                                                            |          }d d d            n# 1 swxY w Y    ||d         d            ||d         d            ||                                d           |                     |                                           | 	                    |
                                t                     | 	                    |
                    d	          t                     d S )
NrY  r  r   r  r   r  rk   TrX   )r2   r&   r   r   r   r  rH   r  r  r  rZ   r   r   r  s       r9   test_bytes_header_parserz$TestParsers.test_bytes_header_parserg  sC   lD)) 	=R,002288<<C	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=
3v;-...
3t9m$$$
3!!#4555))++,,,coo//555cooTo::EBBBBBs   2AAAc                 B   t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          j                            t          j        j                  }|                    |d          }|                     |j	        g            d S )Nz
msg_47.txtrV   r   r   T)headersonly)
r&   r   r   r   r   r   r  r   r2   r  )r6   r   r   r   
parsed_msgs        r9   %test_header_parser_multipart_is_validz1TestParsers.test_header_parser_multipart_is_valids  s    lW555 	 ggiiG	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  $$EL,@$AA__W$_??
+R00000r   c                     t          dd          5 }t          j                                                            |           |                     |j                   d d d            d S # 1 swxY w Y   d S )NrY  r  )r&   r   r   BytesParserr  r  closedr  s     r9   %test_bytes_parser_does_not_close_filez1TestParsers.test_bytes_parser_does_not_close_file}  s    lD)) 	(RL$$&&,,R000RY'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   AA**A.1A.c                 6   t          dd          5 }t          j        j        }|                     t          j        j         |t          j        j                  j	        |           | 
                    |j                   d d d            d S # 1 swxY w Y   d S )Nr  r  r   )r&   r   r   r  r   r    r  r   strictr  r  r  )r6   r   bytesParsers      r9   2test_bytes_parser_on_exception_does_not_close_filez>TestParsers.test_bytes_parser_on_exception_does_not_close_file  s    lD)) 	(R,2KelF)k1DEEEK " " " RY'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   A0BBBc                     t          dd          5 }t          j                                                            |           |                     |j                   d d d            d S # 1 swxY w Y   d S )NrY  rV   r   )r&   r   r   r   r  r  r  r  s     r9   test_parser_does_not_close_filez+TestParsers.test_parser_does_not_close_file  s    lW555 	(L!!''+++RY'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   AA++A/2A/c                 8   t          dd          5 }t          j        j        }|                     t          j        j         |t          j        j                  j	        |           | 
                    |j                   d d d            d S # 1 swxY w Y   d S )Nr  rV   r   r   )r&   r   r   r   r   r    r  r   r  r  r  r  )r6   r   r   s      r9   ,test_parser_on_exception_does_not_close_filez8TestParsers.test_parser_on_exception_does_not_close_file  s    lW555 	(\(FelF$fEL,?@@@FL L LRY'''		( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   A0BBBc                     | j         }t          j        d          } ||d         d            ||d         d            ||                                d           d S )NzFrom: aperson@dom.ain
To: bperson@dom.ain
Subject: the next line has a space on it
 
Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam

Here's the message body
r  !the next line has a space on it
 r  spamHere's the message body
r2   r   r  rZ   r5   s      r9   test_whitespace_continuationz(TestParsers.test_whitespace_continuation  v     ' 	) 	 	 	3y>?@@@
3|f%%%
3??9:::::r;   c                     | j         }t          j        d          } ||d         d            ||d         d            ||                                d           d S )NzFrom: aperson@dom.ain
To: bperson@dom.ain
Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam
Subject: the next line has a space on it
 

Here's the message body
r  r  r  r  r  r  r5   s      r9   (test_whitespace_continuation_last_headerz4TestParsers.test_whitespace_continuation_last_header  r  r;   c                    | j         }t          ddd          5 }t                                          |          }d d d            n# 1 swxY w Y    |t	          |                                          d           |                    d          } ||                                d            ||                                d           |                    d	          } ||                                d
           d S )Nr  rV   r*   r  r   r   r?   z!Simple email with attachment.

r   zapplication/riscos)r2   r&   r   r  r  rZ   rH   )r6   r7   r   r8   part1part2s         r9   test_crlf_separationz TestParsers.test_crlf_separation  s.   lWdCCC 	%r((..$$C	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%
3s  !!1%%%""
5!!##\222
5 GHHH""
5!!##%9:::::s   "AAAc                 b   t          ddd          5 }|                                }d d d            n# 1 swxY w Y   t          j        |          }t	                      }t          |          }|                    |d           |                     |                                |           d S )Nr  rV   r*   r  r   r   r  r  s         r9   test_crlf_flattenzTestParsers.test_crlf_flatten  s    lWdCCC 	r7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'--JJaLL			#v	&&&t,,,,,r  Nc                    | j         }| j        }t          dd          5 }t          j        |          }d d d            n# 1 swxY w Y    ||                                d            |t          |                                          d           |                    d          } ||                                d            ||                                d            |t          |                                          d           |                    d          } ||                                d            ||                                d            ||                                d	           |                    d          } ||                                d            ||                                d            |t          |                                          d           |                    d          } ||                                d            ||                                d            ||                                d
           d S )Nrj  rV   r   r   r   r   ra  r?   r*  r+  )	r2   r  r&   r   r  r  r  rZ   rH   )	r6   r7   r  r   r8   r  part1ar  part2as	            r9   -test_multipart_digest_with_extra_mime_headersz9TestParsers.test_multipart_digest_with_extra_mime_headers  s   #lW555 	.)"--C	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	3q!!!
3s  !!1%%%""
5!!##%5666
5###
3u  ""##Q'''""1%%
6  !$$$
6""$$l333F  -000""
5!!##%5666
5###
3u  ""##Q'''""1%%
6  !$$$
6""$$l333F  -00000s   AAAc                     g d}t          j        t                              |                    }|                     |d         d           d S )N)z$From: Andrew Person <aperson@dom.ainzSubject: Testz%Date: Tue, 20 Aug 2002 16:43:45 +1000datezTue, 20 Aug 2002 16:43:45 +1000)r   r  r   r   r2   )r6   r   r8   s      r9   test_three_lineszTestParsers.test_three_lines  sP    : : : '77V&GHHHHHr;   c                     | j         }d}d}d|d|d}t          j        |          } ||                    d          |            ||                    d          |           d S )Nr   z	more textzHeader: z
Next-Header: z

Body

r   zNext-Header)r2   r   r  get)r6   r7   value1value2r   r8   s         r9   3test_strip_line_feed_and_carriage_return_in_headersz?TestParsers.test_strip_line_feed_and_carriage_return_in_headers  s|    FFFFF'**
3778f%%%
377=!!6*****r;   c                     | j         }d}t          j        |          } |t          |          d            |t	          d |D                       g d            ||                                d           d S )Nz(>From: foo
From: bar
!"#QUX;~: zoo

bodyr   c              3      K   | ]}|V  d S rf   r{   )r   fields     r9   rJ  z9TestParsers.test_rfc2822_header_syntax.<locals>.<genexpr>  s"      ))E%))))))r;   )z!"#QUX;~z>Fromr   r  )r2   r   r  r  r  rZ   r  s       r9   test_rfc2822_header_syntaxz&TestParsers.test_rfc2822_header_syntax  s    :'**
3s88Q
6))S)))))+H+H+HIII
3??f%%%%%r;   c                     | j         }d}t          j        |          } |t          |                                          d           d S )Nz<>From foo@example.com 11:25:53
From: bar
!"#QUX;~: zoo

bodyr   )r2   r   r  r  r  r  s       r9   (test_rfc2822_space_not_allowed_in_headerz4TestParsers.test_rfc2822_space_not_allowed_in_header  sE    N'**
3sxxzz??Ar;   c                     | j         }d}t          j        |          }|                                }|                                  ||g d            ||                                d           d S )Nz7A: first header
B: second header
CC: third header

body)ABCCr  )r2   r   r  r  sortrZ   )r6   r7   r   r8   headerss        r9   !test_rfc2822_one_character_headerz-TestParsers.test_rfc2822_one_character_header  st    I'**((**
7$$$%%%
3??f%%%%%r;   c                     d}t          j        |          }|                     |                    d                                                              d                     d S )NzFrom: foo@bar.com
To: baz
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=BOUNDARY

--BOUNDARY
Content-Type: text/plain

body ending with CRLF newline

--BOUNDARY--
r   r   )r   r  r   rZ   r}  r6   r   r8   s      r9   test_CRLFLF_at_end_of_partz&TestParsers.test_CRLFLF_at_end_of_part  s\    
 	
 '****6688AA&IIJJJJJr;   )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r{   r;   r9   r  r  Z  s4       	6 	6 	6
C 
C 
C1 1 1( ( (
( ( (( ( (
( ( (; ; ;$; ; ;$	; 	; 	;- - - G1 1 1>I I I	+ 	+ 	+& & &  & & &K K K K Kr;   r  c                      e Zd Z ej        d          Zd Zd Zd Zd Z	d Z
d ZdZd	                    d
 eD                       dz                       d          Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z ej        d                              d          Zd Zd Z ej        d          Zd Zd Z d Z!e"                    d	          Z#dge#d d!<   d	                    e#          Z#d" Z$ ej        d#                              d$          Z% ej        d%          Z&d& Z'd' Z(d( Z)d) Z*d* Z+d+ Z,d, Z-d-Z.d-S ).Test8BitBytesHandlingz        From: foo@bar.com
        To: baz
        Mime-Version: 1.0
        Content-Type: text/plain; charset={charset}
        Content-Transfer-Encoding: {cte}

        {bodyline}
        c                 X   | j                             ddd                              d          }t          j        |          }|                     |                                d           |                     |                    d          d                    d                     d S )NrV   r`      pöstalrA   r   bodyline   pöstal
TrX   bodytest_msgr  r   r   r   r2   rZ   r  s      r9   test_known_8bit_CTEz)Test8BitBytesHandling.test_known_8bit_CTEA  s    $$W)/.7 % 9 99? 	
 &q))**K88855$++G44	6 	6 	6 	6 	6r;   c                 X   | j                             ddd                              d          }t          j        |          }|                     |                                d           |                     |                    d          d	                    d                     d S )
Nnotavalidcharsetr`   r  r  rV   u   p��stal
TrX   r!  r"  r  s      r9   test_unknown_8bit_CTEz+Test8BitBytesHandling.test_unknown_8bit_CTEJ  s    $$-?)/.7 % 9 99? 	
 &q))**,ABBB55$++G44	6 	6 	6 	6 	6r;   c                 X   | j                             ddd                              d          }t          j        |          }|                     |                                d           |                     |                    d          d                    d                     d S )	NrV   rC      p=C3=B6stálr  u   p=C3=B6stál
TrX   	   pöstál
r"  r  s      r9   test_8bit_in_quopri_bodyz.Test8BitBytesHandling.test_8bit_in_quopri_bodyS  s     $$W);.< % > >>DfWoo 	
 &q))**,<===55%,,W55	7 	7 	7 	7 	7r;   c                 X   | j                             ddd                              d          }t          j        |          }|                     |                                d           |                     |                    d          d	                    d                     d S )
Nr   rC   r)  r  rV   u   p=C3=B6st��l
TrX   r*  r"  r  s      r9   .test_invalid_8bit_in_non_8bit_cte_uses_replacezDTest8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replacee  s     $$W);.< % > >>DfWoo 	
 &q))**,FGGG55$++G44	6 	6 	6 	6 	6r;   c                 ^   | j                             ddd                              d          }t          j        |          }|                     |                    d          d                    d                     |                     |j        d         t          j
                   d S )	NrV   rW   u   cMO2c3RhbAá=r  TrX   r  r   )r#  r  r   r   r   r2   rZ   r  r  r    r  r  s      r9   test_8bit_in_base64_bodyz.Test8BitBytesHandling.test_8bit_in_base64_bodyu  s     $$W)1.= % ? ??Evg 	
 &q))55"))'22	4 	4 	4ck!n$B	D 	D 	D 	D 	Dr;   c                    | j                             ddd                              d          }t          j        |          }|                     |                    d          d                    d                     d S )NrV   r   u   <,.V<W1A; á r  TrX   u   <,.V<W1A; á 
r"  r  s      r9   test_8bit_in_uuencode_bodyz0Test8BitBytesHandling.test_8bit_in_uuencode_body  s     $$W)3.= % ? ??Evg 	
 &q))55*11'::	< 	< 	< 	< 	<r;   ))zFrom: foo@bar.comr   rI  )u   To: báz)r   z=?unknown-8bit?q?b=C3=A1z?=)uV   Subject: Maintenant je vous présente mon collègue, le pouf célèbre
	Jean de Baddie)r  z=?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=
 =?unknown-8bit?q?_Jean_de_Baddie?=)u   From: göst)r   z=?unknown-8bit?b?Z8O2c3Q=?=r*   c                     g | ]\  }}|S r{   r{   )r   src_s      r9   r   z Test8BitBytesHandling.<listcomp>  s     H H H#q H H Hr;   z
Yes, they are flying.
rV   c                     t          j        | j                  }|                     t	          |                    d                    d           |                     t	          |d                   d           d S )Nr      b��z)r   r   headertest_msgr2   r   r  rh   s     r9   test_get_8bit_headerz*Test8BitBytesHandling.test_get_8bit_header  se    &t':;;SWWT]]++-=>>>SY)9:::::r;   c                     t          j        | j                  }|                     t	          |           t          j        d          j        d | j        D                         d S )Nz                            From: {}
                            To: {}
                            Subject: {}
                            From: {}

                            Yes, they are flying.
                            c                 $    g | ]\  }}|d          S )r   r{   )r   r5  r   s      r9   r   zATest8BitBytesHandling.test_print_8bit_headers.<locals>.<listcomp>  s2     *A *A *A-1h(1+ *A *A *Ar;   )	r   r   r8  r2   r   r   r   r  headertest_headersrh   s     r9   test_print_8bit_headersz-Test8BitBytesHandling.test_print_8bit_headers  s    &t':;;S( *  ! ! "( *A *A(,(?*A *A *AB		C 		C 		C 		C 		Cr;   c                     t          j        | j                  }|                     d |                                D             g d           d S )Nc                 ,    g | ]}t          |          S r{   r   r  s     r9   r   zGTest8BitBytesHandling.test_values_with_8bit_headers.<locals>.<listcomp>  s    ;;;c!ff;;;r;   )rI  r7  ]   Maintenant je vous pr��sente mon coll��gue, le pouf c��l��bre
	Jean de Baddie	   g��st)r   r   r8  assertListEqualr  rh   s     r9   test_values_with_8bit_headersz3Test8BitBytesHandling.test_values_with_8bit_headers  s_    &t':;;;;cjjll;;;2 2 2	3 	3 	3 	3 	3r;   c                     t          j        | j                  }|                     d |                                D             g d           d S )Nc                 P    g | ]#\  }}t          |          t          |          f$S r{   r@  )r   r  r$  s      r9   r   zFTest8BitBytesHandling.test_items_with_8bit_headers.<locals>.<listcomp>  s-    III6Aqs1vvs1vv.IIIr;   )r2  )r   r7  )r  rA  )r   rB  )r   r   r8  rC  r   rh   s     r9   test_items_with_8bit_headersz2Test8BitBytesHandling.test_items_with_8bit_headers  s_    &t':;;IISYY[[III< < <	= 	= 	= 	= 	=r;   c                     t          j        | j                  }|                     d |                    d          D             ddg           d S )Nc                 ,    g | ]}t          |          S r{   r@  r  s     r9   r   zHTest8BitBytesHandling.test_get_all_with_8bit_headers.<locals>.<listcomp>  s    BBBc!ffBBBr;   r   rI  rB  )r   r   r8  rC  r4   rh   s     r9   test_get_all_with_8bit_headersz4Test8BitBytesHandling.test_get_all_with_8bit_headers  s_    &t':;;BBckk&.A.ABBB,02	3 	3 	3 	3 	3r;   c                 h   t          j        t          j        d                              d                    }|                     |                                d           |                     |                                d           |                     |                                d           d S )NuA               Content-Type: text/pl§in; charset=utf-8
            r  u   text/pl�inr   u   pl�in)	r   r   r   r   r   r2   rH   rt  r  rh   s     r9   test_get_content_type_with_8bitz5Test8BitBytesHandling.test_get_content_type_with_8bit  s    &x 8 ( (	""$ $ 	--//1BCCC1133V<<<0022LAAAAAr;   c                 X   t          j        d                    d                    }|                     |                    d          g d           |                     |                    dd          d           |                     |                    dd          d            d S )	Nu(   X-Header: foo=§ne; b§r=two; baz=three
r  r  r  ))r      �ne)u   b�rr  r  FoorN  u   b§r)r   r   r   r2   r  rI   rh   s     r9   test_get_params_with_8bitz/Test8BitBytesHandling.test_get_params_with_8bit  s    &;BB9MMO Oz::GGG	I 	I 	IuZ@@*MMMx
CCTJJJJJr;   c                     t          j        t          j        d                              d                    }|                     |                    d          d           d S )Nn               Content-Type: text/plain; charset=us-ascii;
             title*=us-ascii'en'This%20is%20not%20f§nr  title)rN   enu   This is not f�n)r   r   r   r   r   r2   rI   rh   s     r9   !test_get_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_get_rfc2231_params_with_8bit  sk    &x 8< ( ( vi  " " 	w//6	8 	8 	8 	8 	8r;   c                     t          j        t          j        d                              d                    }|                    dd           |                     |                    d          d           d S )NrR  r  rS  test)r   r   r   r   r   r9  r2   rI   rh   s     r9   !test_set_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_set_rfc2231_params_with_8bit  st    &x 8< ( ( vi  " " 	gv&&&w//88888r;   c                 D   t          j        t          j        d                              d                    }|                    d           |                     |                    d          d            |                     |                                d           d S )NrR  r  rS  r   )	r   r   r   r   r   rC  r2   rI   rt  rh   s     r9   !test_del_rfc2231_params_with_8bitz7Test8BitBytesHandling.test_del_rfc2231_params_with_8bit  s    &x 8< ( ( vi  " " 	gw//6661133V<<<<<r;   c                    t          j        t          j        d                              d                    }|                     |                                d           |                     |                    d          d           d S )Nu               Content-Transfer-Encoding: b§se64
            Content-Type: text/plain; charset=latin-1

            payload
            r  zpayload
TrX   s   payload
)r   r   r   r   r   r2   rZ   rh   s     r9   %test_get_payload_with_8bit_cte_headerz;Test8BitBytesHandling.test_get_payload_with_8bit_cte_header  s    &x 8 ( (
 	""$ $ 	**K88855|DDDDDr;   u0          From: foo@bar.com
        To: báz
        Subject: Maintenant je vous présente mon collègue, le pouf célèbre
        	Jean de Baddie
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: 8bit

        Да, они летят.
        c                    t          j        | j                  }t                      }t           j                            |                              |           |                     |                                | j                   d S rf   )	r   r   non_latin_bin_msgr   r   r   r   r2   r   r6   r8   r   s      r9   test_bytes_generatorz*Test8BitBytesHandling.test_bytes_generator  si    &t'=>>ii&&s++33C888)?@@@@@r;   c                    t           j                                        }t                      }t           j                            |                              |           |                     |                                d           d S )Nr   )	r   rw  r   r   r   r   r   r2   r   r_  s      r9   &test_bytes_generator_handles_None_bodyz<Test8BitBytesHandling.test_bytes_generator_handles_None_body  sf    m##%%ii&&s++33C888/////r;   a          From: foo@bar.com
        To: =?unknown-8bit?q?b=C3=A1z?=
        Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue?=
         =?unknown-8bit?q?=2C_le_pouf_c=C3=A9l=C3=A8bre?=
         =?unknown-8bit?q?_Jean_de_Baddie?=
        Mime-Version: 1.0
        Content-Type: text/plain; charset="utf-8"
        Content-Transfer-Encoding: base64

        0JTQsCwg0L7QvdC4INC70LXRgtGP0YIuCg==
        c                    t          j        | j                  }t                      }t           j                            |                              |           |                     |                                | j	                   d S rf   )
r   r   r^  r   r   r   r   r2   r    non_latin_bin_msg_as7bit_wrappedr_  s      r9   test_generator_handles_8bitz1Test8BitBytesHandling.test_generator_handles_8bit%  si    &t'=>>jj!!#&&..s333)NOOOOOr;   c                    t          j        | j                  }t                      }t	          |                              |           |                                }t          t                                                    |           t                      }t	          |                              |           | 	                    |                                |           d S rf   )
r   r   r^  r   r   r   r   r   r   r2   )r6   r8   r   
orig_values       r9   ;test_str_generator_should_not_mutate_msg_when_handling_8bitzQTest8BitBytesHandling.test_str_generator_should_not_mutate_msg_when_handling_8bit+  s    &t'=>>iis##C(((\\^^
(**%%c***iis##C(((44444r;   c                    t          j        | j                  }t                      }t           j                            |                              |d           |                                                    d          }| 	                    |d                                         d         d           | 	                    d
                    |dd                    | j                   d S )NTr   r   r   s   Fromr   )r   r   r^  r   r   r   r   r   r   r2   r   )r6   r8   r   r   s       r9   #test_bytes_generator_with_unix_fromz9Test8BitBytesHandling.test_bytes_generator_with_unix_from5  s     &t'=>>ii&&s++33C$3GGG$$U++q))!,g666E!""I..0FGGGGGr;   zkSubject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=r   r   c                    d}|                      t          |           t          |d          5 }|                    | j                   d d d            n# 1 swxY w Y   t          |d          5 }t
          j                                                            |          }d d d            n# 1 swxY w Y   | 	                    t          |          | j                   d S )Nztest.msgwbr  )
addCleanupr%   openwriter^  r   r   r  r  r2   r   non_latin_bin_msg_as7bit)r6   r  testfiler   s       r9   test_message_from_binary_filez3Test8BitBytesHandling.test_message_from_binary_fileF  s6   ###"d^^ 	3xNN41222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3"d^^ 	;x((**00::A	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;Q!>?????s#   AAA02B..B25B2u          From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="latin-1"
        Content-Transfer-Encoding: 8bit

        oh là là, know what I mean, know what I mean?
        r  a           From: foo@bar.com
        To: Dinsdale
        Subject: Nudge nudge, wink, wink
        Mime-Version: 1.0
        Content-Type: text/plain; charset="iso-8859-1"
        Content-Transfer-Encoding: quoted-printable

        oh l=E0 l=E0, know what I mean, know what I mean?
        c                     t          j        | j                  }|                     t	          |          | j                   d S rf   )r   r   latin_bin_msgr2   r   latin_bin_msg_as7bitr  s     r9   :test_string_generator_reencodes_to_quopri_when_appropriatezPTest8BitBytesHandling.test_string_generator_reencodes_to_quopri_when_appropriatee  s:    $T%788Q!:;;;;;r;   c                 >   t          j        | j                  }t                      }t           j                            |                              |           |                     |                                | j        	                    d          dz              d S )Nr  r*   )
r   r   rt  r   r   r   r   r2   r   rY   )r6   r   r   s      r9   )test_decoded_generator_emits_unicode_bodyz?Test8BitBytesHandling.test_decoded_generator_emits_unicode_bodyi  s    $T%788jj((--55a888 	%%i005	7 	7 	7 	7 	7r;   c                 P   t           j                                        }t          dt	          | j                  d          D ]'}|                    | j        ||dz                       (|                                }|                     t          |          | j
                   d S )Nr   rK  )r   r  r)   rO  r  rt  r  r  r2   r   ru  )r6   bfprI  r   s       r9   test_bytes_feedparserz+Test8BitBytesHandling.test_bytes_feedparsers  s    ..00q#d011266 	1 	1AHHT'!B$/0000IIKKQ!:;;;;;r;   c                 ~   t          dd          5 }|                                }d d d            n# 1 swxY w Y   t          j        |          }t	                      }t          j                            |          }|                    |d           |                     |	                                |           d S )Nr  r  r   r   )
r&   r   r   r   r   r   r   r   r2   r   r  s         r9   r  z'Test8BitBytesHandling.test_crlf_flattenz  s    lD)) 	R7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	&t,,IIO**1--			#v	&&&t,,,,,r  c                 P   t          j        d                              d          }t          j        |          }t                      }t          j                            |          }|                    |           | 	                    |
                                |           d S )Nuo              Date: Fri, 18 Mar 2011 17:15:43 +0100
            To: foo@example.com
            From: foodwatch-Newsletter <bar@example.com>
            Subject: Aktuelles zu Japan, Klonfleisch und Smiley-System
            Message-ID: <76a486bee62b0d200f33dc2ca08220ad@localhost.localdomain>
            MIME-Version: 1.0
            Content-Type: multipart/alternative;
                    boundary="b1_76a486bee62b0d200f33dc2ca08220ad"

            --b1_76a486bee62b0d200f33dc2ca08220ad
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: 8bit

            Guten Tag, ,

            mit großer Betroffenheit verfolgen auch wir im foodwatch-Team die
            Nachrichten aus Japan.


            --b1_76a486bee62b0d200f33dc2ca08220ad
            Content-Type: text/html; charset="utf-8"
            Content-Transfer-Encoding: 8bit

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/html4/loose.dtd">
            <html lang="de">
            <head>
                    <title>foodwatch - Newsletter</title>
            </head>
            <body>
              <p>mit gro&szlig;er Betroffenheit verfolgen auch wir im foodwatch-Team
                 die Nachrichten aus Japan.</p>
            </body>
            </html>
            --b1_76a486bee62b0d200f33dc2ca08220ad--

            rV   )r   r   r   r   r   r   r   r   r   r2   r   )r6   r   r8   r   r   s        r9   test_8bit_multipartz)Test8BitBytesHandling.test_8bit_multipart  s     %" % %J K 	L &v..IIO**1--			#v.....r;   c                    t                      }t          d          |d<   t                      }t          j                            |          }|                    |d           |                     |                                d           d S )N   žluťoučký kůňr  r   r   s5   Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	r   r   r   r   r   r   r   r2   r   r6   r   r   r   s       r9   'test_bytes_generator_b_encoding_linesepz=Test8BitBytesHandling.test_bytes_generator_b_encoding_linesep  s    II344)IIO**1--			!V	$$$JJLLH	J 	J 	J 	J 	Jr;   c                    t                      }t          d          |d<   t                      }t          j                            |          }|                    |d           |                     |                                d           d S )Nr  r  r   r   z5Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=

)	r   r   r   r   r   r   r   r2   r   r  s       r9   !test_generator_b_encoding_linesepz7Test8BitBytesHandling.test_generator_b_encoding_linesep  s    II344)JJO%%a((			!V	$$$JJLLG	I 	I 	I 	I 	Ir;   N)/r  r  r  r   r   r#  r$  r'  r+  r-  r/  r1  r<  r   r   r8  r9  r=  rD  rG  rJ  rL  rP  rU  rX  rZ  r\  r^  r`  rb  rd  re  rh  rj  r   rp  rr  rt  ru  rv  rx  r{  r  r~  r  r  r  r{   r;   r9   r  r  .  s"        #8? $  L6 6 66 6 67 7 7$6 6 6 D D D< < <	
 ii H H5G H H HII#$%+VG__ ; ; ;
C C C	3 	3 	3
= 
= 
=3 3 3B B BK K K8 8 89 9 9= = =E E E ( 
) 
 
 VG__ A A A0 0 0 (7x 8 ( ($P P P5 5 5	H 	H 	H  @EEdKK	8%9QqS!  $yy)ABB@ @ @ $HO 	% 	 	 VI  +8? 	, 	 	< < <7 7 7< < <- - -,/ ,/ ,/\
J 
J 
J
I 
I 
I GGGr;   r  c                        e Zd ZdZd ZddZdS ) BaseTestBytesGeneratorIdempotentNc                     t          |d          5 }|                                }d d d            n# 1 swxY w Y   | j                            | j        |          }t          j        |          }||fS )Nr  )r&   r   normalize_linesep_regexsubblinesepr   r   rK  s        r9   r3   z(BaseTestBytesGeneratorIdempotent._msgobj  s    h%% 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	+//tDD&t,,Dyr  Fc                     t                      }t          j                            |d          }|                    ||| j                   |                     ||                                           d S )Nr   r{  )r   r   )r   r   r   r   r   r   r2   r   )r6   r8   r\   r   r  r   s         r9   rM  z,BaseTestBytesGeneratorIdempotent._idempotent  sc    IIO**11*==			#$,	???qzz||,,,,,r;   r  )r  r  r  r  r3   rM  r{   r;   r9   r  r    s<        G  - - - - - -r;   r  c                   6    e Zd ZdZdZ ej        d          ZdS )TestBytesGeneratorIdempotentNLr*   r   s   \r\nNr  r  r  r   r  recompiler  r{   r;   r9   r  r    s,        GH(bj22r;   r  c                   6    e Zd ZdZdZ ej        d          ZdS ) TestBytesGeneratorIdempotentCRLFr   r  s	   (?<!\r)\nNr  r{   r;   r9   r  r    s,        GH(bj77r;   r  c                   &    e Zd Zd Zd Zd Zd ZdS )
TestBase64c           	      V   | j         } |t          j        d          t          t          j        dd                               t          d          D ]R}|dk    rd}n&|dk    rd}n|d	k    rd
}n|dk    rd}n|dk    rd}nd} |t          j        d|z            |           Sd S )Nhello   hellor+   eol   r   r   r   r     r     r     r  )r2   r   header_lengthr  body_encoderO  )r6   r7   sizebsizes       r9   test_lenzTestBase64.test_len  s    
:#G,,z%hB77788	: 	: 	:"II 	< 	<DQUUQUUQUURUURUU%'UBz'd
33U;;;;	< 	<r;   c                     | j         } |t          j        d          d            |t          j        d          d           d S )Nr+   r;   zaGVsbG8=r  )r2   r   rY   r  s     r9   test_decodezTestBase64.test_decode  sJ    
:R  #&&&
:Z(((33333r;   c                 J   | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        dd	          d
            |t          j        ddd          d           d S )Nr;   r+   r  z	aGVsbG8=
s   hello
z	aGVsbG8K
sd   xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx (   r&  zeHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
r   r'  r  zeHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
)r2   r   r  r  s     r9   test_encodezTestBase64.test_encode  s    
:!#&&+++
:!(++\:::
:!*--|<<<
:!-B??? B 	 	 	 	:!-BFKKK	 	 	 	 	r;   c                    | j         }t          j        } | |d          d            | |d          d            | |d          d            | |dd          d	            | |d          d           d S )
Nr  z=?iso-8859-1?b?aGVsbG8=?=hello
worldz!=?iso-8859-1?b?aGVsbG8NCndvcmxk?=hello
worldz!=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=rr   rS  z=?iso-8859-2?b?aGVsbG8=?=)r2   r   r  )r6   r7   hes      r9   test_header_encodezTestBase64.test_header_encode  s    %
22g;;3444
22!DEEE
22nBCCC
22g|,,,.IJJJ
22nBCCCCCr;   N)r  r  r  r  r  r  r  r{   r;   r9   r  r    sU        < < <4 4 4
  ,D D D D Dr;   r  c                      e Zd Zd Zd Zd Zd Zd Zd ZdEdZ	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdEdZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d  Z!d! Z"d" Z#d# Z$d$ Z%d% Z&d& Z'd' Z(d( Z)d) Z*d* Z+d+ Z,dFd,Z-d- Z.d. Z/d/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;d; Z<d< Z=d= Z>d> Z?d? Z@d@ ZAdA ZBdB ZCdC ZDdD ZEdS )G
TestQuopric                      t          t          t          t          d          t          d          dz             t          t          d          t          d          dz             t          t          d          t          d          dz             d d	D                                  _         fd
t          d          D              _        t          t          t          d          t          d          dz                        _         j                            t          d                      j                            t          d                      fdt          d          D              _	        d S )Nr  zr   r  Zr  9c              3      K   | ]}|V  d S rf   r{   )r   r  s     r9   rJ  z#TestQuopri.setUp.<locals>.<genexpr>(  s"      !!1Q!!!!!!r;   s   !*+-/c                 &    g | ]}|j         v|S r{   )hlitr   r  r6   s     r9   r   z$TestQuopri.setUp.<locals>.<listcomp>+  %    AAA1aty.@.@Q.@.@.@r;      r,   ~r  =c                 &    g | ]}|j         v|S r{   )blitr  s     r9   r   z$TestQuopri.setUp.<locals>.<listcomp>4  r  r;   )
r  r   rO  ordr  hnonr  r(  removebnonr  s   `r9   r  zTestQuopri.setUp!  s9    #c((CHHqL))#c((CHHqL))#c((CHHqL))!!!!!	# # $ $	 BAAAc

AAA	 s3xxSA6677		T###	S""" BAAAc

AAA			r;   c                    | j         D ]:}|                     t          j        |          dt	          |          z             ;| j        D ]:}|                     t          j        |          dt	          |          z             ;d S )Nz'Should not be header quopri encoded: %sz#Should be header quopri encoded: %s)r  r  r"   header_checkchrr  r   r6   r  s     r9   test_quopri_header_checkz#TestQuopri.test_quopri_header_check7  s     	L 	LAZ4Q77ACFFJL L L L 	L 	LAOOJ3A66ACFFJL L L L	L 	Lr;   c                    | j         D ]:}|                     t          j        |          dt	          |          z             ;| j        D ]:}|                     t          j        |          dt	          |          z             ;d S )Nz%Should not be body quopri encoded: %sz!Should be body quopri encoded: %s)r  r  r"   
body_checkr  r  r   r  s     r9   test_quopri_body_checkz!TestQuopri.test_quopri_body_check?  s     	J 	JAZ2155?#a&&HJ J J J 	J 	JAOOJ1!44?#a&&HJ J J J	J 	Jr;   c           	         | j         } |t          j        d          d            |t          t          j        dd                    t          j        d          dz               |t          j        d          d            |t          t          j        dd                    t          j        d          dz              | j        D ]?} |t          j        t          |g                    dd	t          |          z             @| j        D ]S}|t          d
          k    r |t          j        t          |g                    ddt          |          z             T |t          j        d          d           d S )Nr  r  xxxrS  rK  s
   h@e@l@l@o@r  r   zexpected length 1 for %rr,   r   zexpected length 3 for %r    )
r2   r"   r  r  r  r  r   r  r  r  r6   r7   r  s      r9   test_header_quopri_lenz!TestQuopri.test_header_quopri_lenG  s   
:#H--q111
3z'%@@@AA#H--	 	 	 	:#M22B777
3z'uEEEFF#M22	 	 	  	4 	4ABz'qc

33Q)CFF24 4 4 4 	4 	4ACHH}}Bz'qc

33Q)CFF24 4 4 4
:#D))1-----r;   c                     | j         }| j        D ].} |t          j        t	          |g                    d           /| j        D ].} |t          j        t	          |g                    d           /d S )Nr   r   )r2   r  r"   body_lengthr   r  r  s      r9   test_body_quopri_lenzTestQuopri.test_body_quopri_len`  s     	6 	6ABz%eQCjj1115555 	6 	6ABz%eQCjj1115555	6 	6r;   c                     t          d          D ]K}t          |          }|                     t          j        t          j        |                    |           Ld S )Nr  )rO  r  r2   r"   r*  quote)r6   r  r  s      r9   test_quote_unquote_idempotentz(TestQuopri.test_quote_unquote_idempotentg  s_    s 	I 	IAAAZ/
0@0C0CDDaHHHH	I 	Ir;   Nc                     |t          j        |          }nt          j        ||          }|                     ||           d S rf   )r"   r  r2   )r6   r   expected_encoded_headerrA   encoded_headers        r9   _test_header_encodezTestQuopri._test_header_encodel  sH    ?'5f==NN'5fgFFN)@AAAAAr;   c                 2    |                      dd           d S )Nr;   r+   r  r  s    r9   test_header_encode_nullz"TestQuopri.test_header_encode_nulls  s      b)))))r;   c                 2    |                      dd           d S )Nr  z=?iso-8859-1?q?hello?=r  r  s    r9   test_header_encode_one_wordz&TestQuopri.test_header_encode_one_wordv  s      +CDDDDDr;   c                 2    |                      dd           d S )Ns   hello
worldz=?iso-8859-1?q?hello=0Aworld?=r  r  s    r9   test_header_encode_two_linesz'TestQuopri.test_header_encode_two_linesy  s.       @	B 	B 	B 	B 	Br;   c                 2    |                      dd           d S )Ns   hellotherez=?iso-8859-1?q?hello=C7there?=r  r  s    r9   test_header_encode_non_asciiz'TestQuopri.test_header_encode_non_ascii}  s/      !2 @	B 	B 	B 	B 	Br;   c                 6    |                      ddd           d S )Nr  z=?iso-8859-2?q?hello?=rr   rS  r  r  s    r9   test_header_encode_alt_charsetz)TestQuopri.test_header_encode_alt_charset  s1      +C$ 	! 	& 	& 	& 	& 	&r;   c                 Z    t          j        |          }|                     ||           d S rf   )r"   header_decoder2   )r6   r  expected_decoded_headerdecoded_headers       r9   _test_header_decodezTestQuopri._test_header_decode  s/    #1.AA)@AAAAAr;   c                 2    |                      dd           d S Nr+   r  r  s    r9   test_header_decode_nullz"TestQuopri.test_header_decode_null  s      R(((((r;   c                 2    |                      dd           d S Nr  r  r  s    r9   test_header_decode_one_wordz&TestQuopri.test_header_decode_one_word  s      '22222r;   c                 2    |                      dd           d S )Nzhello=0Aworldr  r  r  s    r9   test_header_decode_two_linesz'TestQuopri.test_header_decode_two_lines  s      .AAAAAr;   c                 2    |                      dd           d S )Nzhello=C7thereu   helloÇtherer  r  s    r9   test_header_decode_non_asciiz'TestQuopri.test_header_decode_non_ascii  s      2BCCCCCr;   c                 V    |                      t          j        d          d           d S )Na  =30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30=30  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r2   r"   r  r  s    r9   test_header_decode_re_bug_18380z*TestQuopri.test_header_decode_re_bug_18380  s)    1+>>	JJJJJr;   c                     |t          j        |          }nt          j        ||          }|                     ||           d S )Nr  )r"   rY   r2   )r6   encodedexpected_decodedr  decodeds        r9   _test_decodezTestQuopri._test_decode  sK    ; '00GG 'S999G"233333r;   c                 2    |                      dd           d S r  r  r  s    r9   test_decode_null_wordz TestQuopri.test_decode_null_word      "b!!!!!r;   c                 2    |                      dd           d S )Nr   r*   r  r  s    r9   test_decode_null_line_null_wordz*TestQuopri.test_decode_null_line_null_word  s    &$'''''r;   c                 2    |                      dd           d S r  r  r  s    r9   test_decode_one_wordzTestQuopri.test_decode_one_word  s    '7+++++r;   c                 6    |                      ddd           d S )Nr  Xr  r  r  s    r9   test_decode_one_word_eolz#TestQuopri.test_decode_one_word_eol  s#    '744444r;   c                 2    |                      dd           d S Nhello
hello
r  r  s    r9   test_decode_one_linezTestQuopri.test_decode_one_line      +y11111r;   c                 2    |                      dd           d S Nr
  r  r  s    r9   test_decode_one_line_lfz"TestQuopri.test_decode_one_line_lf      )Y/////r;   c                 2    |                      dd           d S )Nzhellor
  r  r  s    r9   test_decode_one_line_crz"TestQuopri.test_decode_one_line_cr  r  r;   c                 6    |                      ddd           d S )Nr
  helloXr  r  r  r  s    r9   test_decode_one_line_nlz"TestQuopri.test_decode_one_line_nl  s#    )X377777r;   c                 6    |                      ddd           d S )Nr	  r  r  r  r  r  s    r9   test_decode_one_line_crnlz$TestQuopri.test_decode_one_line_crnl  s#    +xS99999r;   c                 2    |                      dd           d S )Nr  r  r  r  s    r9   test_decode_one_line_one_wordz(TestQuopri.test_decode_one_line_one_word  s    *N;;;;;r;   c                 6    |                      ddd           d S )Nr  helloXworldr  r  r  r  s    r9   !test_decode_one_line_one_word_eolz,TestQuopri.test_decode_one_line_one_word_eol  s$    *MsCCCCCr;   c                 2    |                      dd           d S )Nhello
world
hello
world
r  r  s    r9   test_decode_two_linesz TestQuopri.test_decode_two_lines  s     .0@AAAAAr;   c                 6    |                      ddd           d S )Nr  helloXworldXr  r  r  r  s    r9   test_decode_two_lines_eolz$TestQuopri.test_decode_two_lines_eol  s$    .CHHHHHr;   c                 2    |                      dd           d S )N  SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamr  r  s    r9   test_decode_one_long_linez$TestQuopri.test_decode_one_long_line  s    ,55555r;   c                 2    |                      dd           d S )Nr,   r+   r  r  s    r9   test_decode_one_spacez TestQuopri.test_decode_one_space  s    #r"""""r;   c                 2    |                      dd           d S )Nz     r+   r  r  s    r9   test_decode_multiple_spacesz&TestQuopri.test_decode_multiple_spaces  s    '2&&&&&r;   c                 2    |                      dd           d S )Nzhello    
r
  r  r  s    r9   $test_decode_one_line_trailing_spacesz/TestQuopri.test_decode_one_line_trailing_spaces  s    /955555r;   c                 2    |                      dd           d S )Nzhello    
world   
r  r  r  s    r9   %test_decode_two_lines_trailing_spacesz0TestQuopri.test_decode_two_lines_trailing_spaces  s     57GHHHHHr;   c                 2    |                      dd           d S )Nz=22quoted=20words=22z"quoted words"r  r  s    r9   test_decode_quoted_wordz"TestQuopri.test_decode_quoted_word  s     02BCCCCCr;   c                 2    |                      dd           d S )Nzab=CD=EF   abÍïr  r  s    r9   test_decode_uppercase_quotingz(TestQuopri.test_decode_uppercase_quoting      *l33333r;   c                 2    |                      dd           d S )Nzab=cd=efr2  r  r  s    r9   test_decode_lowercase_quotingz(TestQuopri.test_decode_lowercase_quoting  r4  r;   c                 2    |                      dd           d S )Nzsoft line=
breakzsoft linebreakr  r  s    r9   test_decode_soft_line_breakz&TestQuopri.test_decode_soft_line_break  s     /1ABBBBBr;   c                 2    |                      dd           d S )NzA=1,B=A ==> A+B==2r  r  s    r9   test_decode_false_quotingz$TestQuopri.test_decode_false_quoting  s     .0DEEEEEr;   c                    i }|d}n||d<   |d}n||d<   t          j        |fi |}|                     ||           |dk    s|dk    r:|                                D ]'}|                     t          |          |           &d S d S )Nr  r'  r*   r  r   )r"   r  r2   r  r  r  )r6   r  expected_encoded_bodyr'  r  kwargsencoded_bodyr  s           r9   _test_encodezTestQuopri._test_encode  s    JJ#-F< ;CCF5M!-d==f=='<===$;;#-- %//11 < <$$SYY
;;;;	 (-< <r;   c                 2    |                      dd           d S r  r?  r  s    r9   test_encode_nullzTestQuopri.test_encode_null  r  r;   c                 2    |                      dd           d S )Nz

rA  r  s    r9   test_encode_null_linesz!TestQuopri.test_encode_null_lines  s    &&)))))r;   c                 2    |                      dd           d S r  rA  r  s    r9   test_encode_one_linezTestQuopri.test_encode_one_line  r  r;   c                 2    |                      dd           d S r  rA  r  s    r9   test_encode_one_line_crlfz$TestQuopri.test_encode_one_line_crlf  r  r;   c                 6    |                      ddd           d S )Nr
  r	  r   r  rA  r  s    r9   test_encode_one_line_eolz#TestQuopri.test_encode_one_line_eol  s#    )[f=====r;   c                     |                      d                    d                              d          dd           d S )Nu   helloυ
rV   latin1zhello=CF=85
r   r  )r?  r   rY   r  s    r9   (test_encode_one_line_eol_after_non_asciiz3TestQuopri.test_encode_one_line_eol_after_non_ascii  sL    /0099@@JJ+ 	 	9 	9 	9 	9 	9r;   c                 2    |                      dd           d S )Nr,   z=20rA  r  s    r9   test_encode_one_spacez TestQuopri.test_encode_one_space  s    #u%%%%%r;   c                 2    |                      dd           d S )Nz 
z=20
rA  r  s    r9   test_encode_one_line_one_spacez)TestQuopri.test_encode_one_line_one_space  s    %)))))r;   c                 2    |                      dd           d S )Nz 
 
z=20
=20
rA  r  s    r9   test_encode_two_lines_one_spacez*TestQuopri.test_encode_two_lines_one_space  s    (L11111r;   c                 2    |                      dd           d S )Nzhello   z
hello  =20rA  r  s    r9   $test_encode_one_word_trailing_spacesz/TestQuopri.test_encode_one_word_trailing_spaces  r4  r;   c                 2    |                      dd           d S )Nz	hello   
zhello  =20
rA  r  s    r9   $test_encode_one_line_trailing_spacesz/TestQuopri.test_encode_one_line_trailing_spaces  s    ,77777r;   c                 2    |                      dd           d S )Nzhello  	z
hello  =09rA  r  s    r9   !test_encode_one_word_trailing_tabz,TestQuopri.test_encode_one_word_trailing_tab!  s    +|44444r;   c                 2    |                      dd           d S )Nz	hello  	
zhello  =09
rA  r  s    r9   !test_encode_one_line_trailing_tabz,TestQuopri.test_encode_one_line_trailing_tab$  s    -88888r;   c                 6    |                      ddd           d S )N
abcd 
1234zabcd =

1234r  r&  rA  r  s    r9   ,test_encode_trailing_space_before_maxlinelenz7TestQuopri.test_encode_trailing_space_before_maxlinelen'  s$    -)9aHHHHHr;   c                 6    |                      ddd           d S )Nr]  zabcd=
=20
1234r  r&  rA  r  s    r9   (test_encode_trailing_space_at_maxlinelenz3TestQuopri.test_encode_trailing_space_at_maxlinelen*  $    -);JJJJJr;   c                 6    |                      ddd           d S )Nr]  zabc=
d=20
1234r   r&  rA  r  s    r9   ,test_encode_trailing_space_beyond_maxlinelenz7TestQuopri.test_encode_trailing_space_beyond_maxlinelen-  ra  r;   c                 2    |                      dd           d S )Nz
 
 
 
 
 
z=20
=20
=20
=20
=20
rA  r  s    r9   test_encode_whitespace_linesz'TestQuopri.test_encode_whitespace_lines0  s    )[11111r;   c                 2    |                      dd           d S )Nza = bza =3D brA  r  s    r9   test_encode_quoted_equalsz$TestQuopri.test_encode_quoted_equals3  s    '9-----r;   c                 2    |                      dd           d S )Ndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxrA  r  s    r9   test_encode_one_long_stringz&TestQuopri.test_encode_one_long_string6  s    )%@AAAAAr;   c                 2    |                      dd           d S )Nzexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxx
rA  r  s    r9   test_encode_one_long_linez$TestQuopri.test_encode_one_long_line9  s     *,NOOOOOr;   c                 2    |                      dd           d S )Nzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rA  r  s    r9   test_encode_one_very_long_linez)TestQuopri.test_encode_one_very_long_line<  s*    *8	: 	: 	: 	: 	:r;   c                 6    |                      ddd           d S )Nz=====z=3D=
=3D=
=3D=
=3D=
=3Dr   r&  rA  r  s    r9   test_encode_shortest_maxlinelenz*TestQuopri.test_encode_shortest_maxlinelen@  s$    '#7AFFFFFr;   c                 N    |                      t          | j        ddd           d S )Nr+   r   r&  )r   rX  r?  r  s    r9    test_encode_maxlinelen_too_smallz+TestQuopri.test_encode_maxlinelen_too_smallC  s*    *d&7RANNNNNr;   c                    | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        dd          d            |t          j        ddd	
          d            |t          j        d          d           d S )Nr+   r  r  r  dxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx r  r&  zjxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20r   r  zlxxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20zone line

two line)r2   r"   r  r  s     r9   r  zTestQuopri.test_encodeF  s    
:!"%%r***
:!'**G444
:!"233^DDD
:!,2>>> A 	 	 	
 	:!,26JJJ	 	 	
 	:! #  	 	 	 	 	r;   rf   )NN)Fr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r#  r&  r(  r*  r,  r.  r0  r3  r6  r8  r:  r?  rB  rD  rF  rH  rJ  rM  rO  rQ  rS  rU  rW  rY  r[  r^  r`  rc  re  rg  rj  rl  rn  rp  rr  r  r{   r;   r9   r  r     s\       6 6 6,L L LJ J J. . .26 6 6I I I
B B B B* * *E E EB B BB B B& & &B B B) ) )3 3 3B B BD D DK K K4 4 4 4" " "( ( (, , ,5 5 52 2 20 0 00 0 08 8 8: : :< < <D D DB B BI I I6 6 6# # #' ' '6 6 6I I ID D D4 4 44 4 4C C CF F F< < < <(" " "* * *0 0 02 2 2> > >9 9 9
& & &* * *2 2 24 4 48 8 85 5 59 9 9I I IK K KK K K2 2 2. . .B B BP P P: : :G G GO O O    r;   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestCharsetc                 F    ddl m} 	 |j        d= d S # t          $ r Y d S w xY w)Nr   rS  fake)r   rA   CHARSETSr  )r6   CharsetModules     r9   tearDownzTestCharset.tearDownc  sL    222222	&v... 	 	 	DD	s    
  c                    | j         }t          d          } ||                    d          d           d}|                     t          |j        |           t          d          } ||                    |          d           d S )NrN   Hello World!u   ¤¢¤¤¤¦¤¨¤ªrV   z(=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=)r2   r
   r  r   r!  )r6   r7   r  r   s       r9   test_codec_encodeablez!TestCharset.test_codec_encodeablej  s    J
1??>**N;;;6,;;;G
1??1IJJJJJr;   c                    | j         }t          d          } |d|                    d                     t          d          } |d|                    d                     t          d          } |d|                    d                     t          d	          }d
dlm} |                    d|j        d d           t          d          } |d|                    d                     d S )Nr=   zhello w=F6rldu   hello wörldrV   rl  r   rN   r  r  r   rS  rx  )r2   r
   r  r   rA   add_charsetQP)r6   r7   r  rz  s       r9   test_body_encodezTestCharset.test_body_encodeu  s    L!!
?AMM*:;;<<<G
~!>!>???J
=!--66777H 	322222!!&-*:D'JJJFOO
=!--6677777r;   c                     t          d          }|                     t          |          d           |                     t          j        t           d           d S )NrN   u   ascÿii)r
   r2   r   r   r    CharsetErrorri  s     r9   test_unicode_charset_namez%TestCharset.test_unicode_charset_name  sL    *%%Wz222&-wDDDDDr;   N)r  r  r  r{  r~  r  r  r{   r;   r9   rv  rv  b  sX          	K 	K 	K8 8 8>E E E E Er;   rv  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )
TestHeaderc                     | j         }t          d          } ||                                d           |                    d            ||                                d           d S )Nr}  z Goodbye World!zHello World!  Goodbye World!r  r   r   r(  r4  s      r9   test_simplezTestHeader.test_simple  se    ">""
188::~&&&	"###
188::566666r;   c                     | j         }t          d          } ||                                d           |                    d            ||                                d           d S )Nr}  zGoodbye World!zHello World! Goodbye World!r  r4  s      r9   test_simple_surprisezTestHeader.test_simple_surprise  se    ">""
188::~&&&	!"""
188::455555r;   c                 V    d}|                      t          |          |d fg           d S )Nzno decoding neededr  r?  s     r9   test_header_needs_no_decodingz(TestHeader.test_header_needs_no_decoding  s1     q))QI;77777r;   c                     t          dd          }|                    d                              d          D ]%}|                     t	          |          d           &d S )Na  I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.r  r&  r,   )
splitcharsz
 )r   r   r   r  r  )r6   r  ls      r9   	test_longzTestHeader.test_long  ss      L " " "S))//66 	- 	-A  Q,,,,	- 	-r;   c                    | j         }t          d          }t          d          }t          d          }d}d}d}t          ||          }|                    ||           |                    ||           |                    d          }	 ||	d	           t          |	          }
 |t          |
          d
            ||
d         |df            ||
d         |df            ||
d         |                    d          df           t          |          } ||d                    d                     t          t          |	                    } |||           d S )Nr=   rr   rV   r!  r"  r#  r  r&  a  =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_kom?=
 =?iso-8859-1?q?fortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wand?=
 =?iso-8859-1?q?gem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6r?=
 =?iso-8859-1?q?dert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?=
 =?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
 =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?=
 =?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?=
 =?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?=
 =?utf-8?b?IE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5k?=
 =?utf-8?b?IGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIA=?=
 =?utf-8?b?44Gj44Gm44GE44G+44GZ44CC?=r   r   r   r   s  Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an südlündischen Wandgemälden vorbei, gegen die rotierenden Klingen befördert. Finančni metropole se hroutily pod tlakem jejich důvtipu.. 正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.」と言っています。)
r  r
   r   r(  r   r   r  r   rY   r   )r6   r7   r   r)  r*  r+  r,  r-  r  encr  ustrnewhs                r9   test_multilingualzTestHeader.test_multilingual  s   "L!!\""wB$0	 61	"	D!!!hh"h%%
3 ) 	* 	* 	*  $$
3w<<
71:-...
71:.///
71:	((117;<<<1vv
4D  fWoo#	 	 	& =--..
4r;   c                 r    t                      }|                     |                                d           d S r  r>  r?  s     r9   test_empty_header_encodez#TestHeader.test_empty_header_encode  s/    HHR(((((r;   c                     | j         }t                      } ||d           |                    dt          d                      ||d           d S )Nr+   r   r=   )r  r   r(  r
   r4  s      r9   test_header_ctor_default_argsz(TestHeader.test_header_ctor_default_args  sQ    "HH
1b				--...
1er;   c                    | j         }d}t          |          } ||                                d            |t          |          |           t          |d          } ||                                d            |t          |          |           t          |dd          } ||                                |            |t          |          |           d S )Nz|A very long line that must get split to something other than at the 76th character boundary to test the non-default behaviorz}A very long line that must get split to something other than at the 76th
 character boundary to test the non-default behaviorr  r$  z}A very long line that must get split to something other than at the
 76th character boundary to test the non-default behaviori   )r'  r%  )r  r   r   r   r  s       r9   test_explicit_maxlinelenz#TestHeader.test_explicit_maxlinelen  s    " 4LL
188:: 8 	9 	9 	9 	3q6644Y///
188:: = 	> 	> 	> 	3q6644Di@@@
188::t
3q664r;   c           
         | j         }t          dd          }d}|                    |           |                                } ||d            ||t	          t          t          |                                         t          dd          }|                    d           |                                } ||d            ||t	          t          t          |                                         d S )Nr=   r  rA   r'  rt  a  =?iso-8859-1?q?xxx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_x?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?x_?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?xx?=
 =?iso-8859-1?q?_?=r  z=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xxx?=
 =?iso-8859-1?q?x_xxxx_xxxx_xxxx_xxxx_?=
 =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=
 =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=
 =?iso-8859-1?q?_xxxx_xxxx_?=r  r   r(  r   r   r   r   r6   r7   r  r  r   s        r9   test_quopri_splittablez!TestHeader.test_quopri_splittable  s   "<B777	HHJJ
1 2 2	 2	 2	f 	1c+mA..//00111<B777	HHJJ
1 ! 	" 	" 	" 	1c+mA..//0011111r;   c           
         | j         }t          dd          }d}|                    |           |                                } ||d            ||t	          t          t          |                                         t          dd          }|                    |           |                                } ||d            ||t	          t          t          |                                         d S )Nrs   r  r  rt  a  =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IHh4?=
 =?koi8-r?b?eHgg?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?eCB4?=
 =?koi8-r?b?eHh4?=
 =?koi8-r?b?IA==?=r  z=?koi8-r?b?eHh4eCB4eHh4IHh4eHggeHh4?=
 =?koi8-r?b?eCB4eHh4IHh4eHggeHh4eCB4?=
 =?koi8-r?b?eHh4IHh4eHggeHh4eCB4eHh4?=
 =?koi8-r?b?IHh4eHggeHh4eCB4eHh4IHh4?=
 =?koi8-r?b?eHggeHh4eCB4eHh4IHh4eHgg?=
 =?koi8-r?b?eHh4eCB4eHh4IA==?=r  r  s        r9   test_base64_splittablez!TestHeader.test_base64_splittableW  s    "8333	HHJJ
1 " "	 "	 "	F 	1c+mA..//001118333	HHJJ
1 " 	# 	# 	# 	1c+mA..//0011111r;   c                     | j         }d}t          |          } ||dg           t          |          } |||                                           d S )Nr  )r  Nr2   r   r   r   )r6   r7   r   r  r  s        r9   test_us_ascii_headerzTestHeader.test_us_ascii_header  s\    !
1   NN
1ahhjjr;   c                 t    | j         }t                      }|                    dd            ||d           d S )Nr  r=   )r2   r   r(  r4  s      r9   test_string_charsetzTestHeader.test_string_charset  s:    HH	,'''
1gr;   c                     | j         }t          dd          } ||                                d           t          dd          } ||                                d           d S )Nr  rV   z=?utf-8?q?p=C3=B6stal?=u   菊地時夫z=?utf-8?b?6I+K5Zyw5pmC5aSr?=r2   r   r   r4  s      r9   test_utf8_shortestzTestHeader.test_utf8_shortest  se    ;((
188::0111-w77
188::566666r;   c                 z   | j         }| j        }d} |t          t          |           t                      } |t          |j        |           |                    dd          } |t          t          |d                    |           |                    |d            |t          |          |           d S )N0   Ynwp4dUEbay Auction Semiar- No Charge  Earn BigrV   r   r   )r   r2   r!  r   r(  rY   r   )r6   rH  r7   r  r  es         r9   test_bad_8bit_headerzTestHeader.test_bad_8bit_header  s    "B|VQ'''HH|QXq)))HHWi((
3va	***++Q///	9%%%
3q661r;   c                 (   d}|                     dd          }t          |t          j        j                  }|                     t          |          d           |                     t          j                            |          |dfg           d S )Nr  r   surrogateescaperS  2   Ynwp4dUEbay Auction Semiar- No Charge � Earn Bigunknown-8bit)	rY   r   r   rA   UNKNOWN8BITr2   r   r   r   )r6   r  r  r  s       r9   test_escaped_8bit_headerz#TestHeader.test_escaped_8bit_header  s    BHHW/001em7888QO	Q 	Q 	Q33A66!^9L8MNNNNNr;   c                     d}t          |t          j        j                  }|                     t          |          d           |                     t          j                            |          |dfg           d S Nr  rS  r  r  )r   r   rA   r  r2   r   r   r   )r6   r  r  s      r9   &test_header_handles_binary_unknown8bitz1TestHeader.test_header_handles_binary_unknown8bit  sx    B1em7888QO	Q 	Q 	Q33A66!^9L8MNNNNNr;   c                 t   d}t          |t          j        j                  }t          j                            t          j                            |                    }|                     t          |          d           |                     t          j                            |          |dfg           d S r  )	r   r   rA   r  r   r   r   r2   r   )r6   r  r  h2s       r9   +test_make_header_handles_binary_unknown8bitz6TestHeader.test_make_header_handles_binary_unknown8bit  s    B1em7888\%%el&@&@&C&CDDRO	Q 	Q 	Q33B771n:M9NOOOOOr;   c                     t          d          }t          j                            |          }|                    d           |                     t          |          d           d S )NrW  )r   test2)r   r   r   r   r(  r2   r   )r6   r  r  s      r9   0test_modify_returned_list_does_not_change_headerz;TestHeader.test_modify_returned_list_does_not_change_header  sW    6NN++A..()))Q(((((r;   c                 :   | j         }t                      }|                    dd           |                    d           |                                } ||d           t	          t          |                    } ||                                |           d S )Nr  r=   worldz=?iso-8859-1?q?hello?= world)r2   r   r(  r   r   r   )r6   r7   r  r   s       r9    test_encoded_adjacent_nonencodedz+TestHeader.test_encoded_adjacent_nonencoded  s    HH	,'''	HHJJ
1,---a(())
188::qr;   c                     | j         }d}t          |          } ||g d           t          |          } ||                                d           d S )NzGSubject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.))s	   Subject: N)s     rs   )s    zz.Nz6Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.r  )r6   r7   r   partshdrs        r9   test_whitespace_keeperz!TestHeader.test_whitespace_keeper  s    Ua  
5  Y  Y  Y  	Z  	Z  	Z%  
3::<<C	E 	E 	E 	E 	Er;   c                 P    | j         }d} |t          j        t          |           d S )NzXSubject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?=)r   r    r   r   )r6   rH  r   s      r9   test_broken_base64_headerz$TestHeader.test_broken_base64_header  s,    "fv&q99999r;   c                 x    t          dd          }|                     |                                d           d S )Nr<  	shift_jisrS  r=  r>  r?  s     r9   test_shift_jis_charsetz!TestHeader.test_shift_jis_charset  s9    5+...%EFFFFFr;   c                 t    t          j        d          }|                     t          |          d           d S )NzEmptyHeader:zEmptyHeader: 

)r   r  r2   r   rh   s     r9   !test_flatten_header_with_no_valuez,TestHeader.test_flatten_header_with_no_value  s7     '77S#677777r;   c                 r    t                      }d|d<   |                     t          |          d           d S )Nz   value with leading ws
SomeHeaderz&SomeHeader:    value with leading ws

)r   r2   r   rh   s     r9   )test_encode_preserves_leading_ws_on_valuez4TestHeader.test_encode_preserves_leading_ws_on_value  s8    ii6LS#MNNNNNr;   c                 p    |                      t          d                                          d           d S )Nr,   r  r  s    r9   test_whitespace_headerz!TestHeader.test_whitespace_header  s0    ++--s33333r;   N)r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r{   r;   r9   r  r    s       7 7 76 6 68 8 8- - -= = =~) ) )    &C2 C2 C2J42 42 42l    7 7 7
 
 
O O OO O OP P P) ) )  E E E: : :
G G G8 8 8O O O
4 4 4 4 4r;   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z dS ) TestRFC2231c                     | j         }|                     d          } ||                    d          d            ||                    dd          d           d S )Nz
msg_29.txtrS  rN   rT  %This is even more ***fun*** isn't it!Fr)  )rN   rT  z'"This is even more ***fun*** isn't it!")r2   r3   rI   r5   s      r9   r$  zTestRFC2231.test_get_param  s{    ll<((
3==!!G	I 	I 	I
3==%=00I	K 	K 	K 	K 	Kr;   c                    | j         }t                      }|                    ddd            ||                    d          d           |                    dddd            ||                    d          d           |                     d	          }|                    dddd            ||                    d
          d           d S )NrS  r  rN   rS  )rN   r+   r  rT  rA   languager  r   rw  r{  a"  Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
	id 27CEAD38CC; Fri,  4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
From: bbb@ddd.com (John X. Doe)
To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset=us-ascii;
 title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21


Hi,

Do you like this message?

-Me
)r  r   r9  rI   r3   r   r5   s      r9   r:  zTestRFC2231.test_set_param  s   "iigG( 	 	* 	* 	*
3==!!E	G 	G 	GgG(4 	 	9 	9 	9
3==!!G	I 	I 	Ill<((gG(4 	 	9 	9 	9
3==b=)) , 	 	 	 	 	r;   c                 V   t                      }|                    dd           |                     |d         d           |                    ddd           |                     |d         d           |                    dd	d           |                     |d         d
           d S )NrS  r   r@   ztext/plain; title="foo"r  F)requoteztext/plain; title=barz	(bar)bellztext/plain; title="(bar)bell")r   r9  r2   rh   s     r9   test_set_param_requotez"TestRFC2231.test_set_param_requote3  s    iigu%%%^,.GHHHgue444^,.EFFFg{E:::^,.MNNNNNr;   c                    | j         }|                     d          }|                    dddd           |                    dddd           |                    dd	
            ||                    d          d           d S )Nr   r   r  rN   rT  r  rS  r  rD   r  rw  r{  a$  Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
	id 27CEAD38CC; Fri,  4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
From: bbb@ddd.com (John X. Doe)
To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset="us-ascii";
 title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21


Hi,

Do you like this message?

-Me
)r  r3   r9  rC  r   r5   s      r9   rE  zTestRFC2231.test_del_param=  s    "ll<((eUJFFFgG 	 	/ 	/ 	/eN333
3==b=)) , 	 	 	 	 	r;   c                 z    | j         }|                     d          } ||                                d           d S )Nrm  rN   )r2   r3   get_content_charsetr5   s      r9    test_rfc2231_get_content_charsetz,TestRFC2231.test_rfc2231_get_content_charset^  s?    ll<((
3""$$j11111r;   c                     t          j        d          }t          j        |          }|                     |                                d           |                     ||                                           d S )Nz            Content-Disposition: inline;
            	filename*0*=''This%20is%20even%20more%20;
            	filename*1*=%2A%2A%2Afun%2A%2A%2A%20;
            	filename*2="is it not.pdf"

            )This is even more ***fun*** is it not.pdfr   r   r   r  r2   r}   r   r  s      r9   test_rfc2231_parse_rfc_quotingz*TestRFC2231.test_rfc2231_parse_rfc_quotingd  z    O    '**))++D	F 	F 	FCMMOO,,,,,r;   c                     t          j        d          }t          j        |          }|                     |                                d           |                     ||                                           d S )Nz            Content-Disposition: inline;
            	filename*0*="''This%20is%20even%20more%20";
            	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
            	filename*2="is it not.pdf"

            r  r  r  s      r9    test_rfc2231_parse_extra_quotingz,TestRFC2231.test_rfc2231_parse_extra_quotingr  r  r;   c                     d}t          j        |          }|                    d          }|                     |t                     |                     |d           d S )Na  Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm"
Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEM; NAME*1=P_nsmail.htm

NAMEzMfile____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htmr   r  rI   assertNotIsInstancetupler2   r6   r   r8   params       r9   #test_rfc2231_no_language_or_charsetz/TestRFC2231.test_rfc2231_no_language_or_charset  so     '**f%%  ...[	] 	] 	] 	] 	]r;   c                     d}t          j        |          }|                     |                                d           d S NzContent-Disposition: inline;
	filename*0*="''This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

r  r	  r  s      r9   /test_rfc2231_no_language_or_charset_in_filenamez;TestRFC2231.test_rfc2231_no_language_or_charset_in_filename  S     '**))++D	F 	F 	F 	F 	Fr;   c                     d}t          j        |          }|                     |                                d           d S r  r	  r  s      r9   7test_rfc2231_no_language_or_charset_in_filename_encodedzCTestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encoded  r  r;   c                     d}t          j        |          }|                     |                                d           d S )NzContent-Disposition: inline;
	filename*0="''This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

z1This%20is%20even%20more%20***fun*** is it not.pdfr	  r  s      r9   test_rfc2231_partly_encodedz'TestRFC2231.test_rfc2231_partly_encoded  sT     '**?	A 	A 	A 	A 	Ar;   c                     d}t          j        |          }|                     |                                d           d S )NzContent-Disposition: inline;
	filename*0="This%20is%20even%20more%20";
	filename*1="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

z?This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdfr	  r  s      r9   test_rfc2231_partly_nonencodedz*TestRFC2231.test_rfc2231_partly_nonencoded  sT     '**M	O 	O 	O 	O 	Or;   c                     d}t          j        |          }|                     |                                d           d S )NzContent-Type: multipart/alternative;
	boundary*0*="''This%20is%20even%20more%20";
	boundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
	boundary*2="is it not.pdf"

r  r  r  s      r9   /test_rfc2231_no_language_or_charset_in_boundaryz;TestRFC2231.test_rfc2231_no_language_or_charset_in_boundary  r  r;   c                     d}t          j        |          }|                     |                                d           d S )NzContent-Type: text/plain;
	charset*0*="This%20is%20even%20more%20";
	charset*1*="%2A%2A%2Afun%2A%2A%2A%20";
	charset*2="is it not.pdf"

z)this is even more ***fun*** is it not.pdfr   r  r2   r  r  s      r9   .test_rfc2231_no_language_or_charset_in_charsetz:TestRFC2231.test_rfc2231_no_language_or_charset_in_charset  sS     '**0022D	F 	F 	F 	F 	Fr;   c                     d}t          j        |          }|                     |                                d           d S )NzContent-Disposition: inline;
	filename*0*="bogus'xx'This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2="is it not.pdf"

r  r	  r  s      r9   %test_rfc2231_bad_encoding_in_filenamez1TestRFC2231.test_rfc2231_bad_encoding_in_filename  r  r;   c                     d}t          j        |          }|                     |                                d            d S )Nz:Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D

r  r  s      r9   $test_rfc2231_bad_encoding_in_charsetz0TestRFC2231.test_rfc2231_bad_encoding_in_charset  E     '** 	0022D99999r;   c                     d}t          j        |          }|                     |                                d            d S )Nz:Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D

r  r  s      r9   %test_rfc2231_bad_character_in_charsetz1TestRFC2231.test_rfc2231_bad_character_in_charset  r  r;   c                     d}t          j        |          }|                     |                                d           d S )NzContent-Disposition: inline;
	filename*0*="ascii'xx'This%20is%20even%20more%20";
	filename*1*="%2A%2A%2Afun%2A%2A%2A%20";
	filename*2*="is it not.pdf%E2"

u,   This is even more ***fun*** is it not.pdf�r	  r  s      r9   &test_rfc2231_bad_character_in_filenamez2TestRFC2231.test_rfc2231_bad_character_in_filename   sS     '**))++J	L 	L 	L 	L 	Lr;   c                     d}t          j        |          }|                     |                                d           d S )Nz^Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt


myfile.txtr	  r  s      r9   test_rfc2231_unknown_encodingz)TestRFC2231.test_rfc2231_unknown_encoding  C    
 '**))++\:::::r;   c                     d}t          j        |          }|                     |                                d           d S )Nuc   Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename*=utf-8''myfile.txt

r
  r	  r  s      r9   &test_rfc2231_bad_character_in_encodingz2TestRFC2231.test_rfc2231_bad_character_in_encoding  r  r;   c                     | j         }d}t          j        |          }|                    d          \  }}} ||d             ||d             ||d           d S )NzJContent-Type: application/x-foo;
	name*0*="Frank's"; name*1*=" Document"

r&  Frank's Documentr#  r6   r7   r   r8   rA   r  r   s          r9   -test_rfc2231_single_tick_in_filename_extendedz9TestRFC2231.test_rfc2231_single_tick_in_filename_extended  sx    
 '**"}}V441
7D
8T
1 !!!!!r;   c                     d}t          j        |          }|                    d          }|                     |t                     |                     |d           d S )NzGContent-Type: application/x-foo; name*0="Frank's"; name*1=" Document"

r&  r  r  r  s       r9   $test_rfc2231_single_tick_in_filenamez0TestRFC2231.test_rfc2231_single_tick_in_filename,  s_     '**f%%  ... 233333r;   c                     d}t          j        |          }|                     |                                d           d S )NzAContent-Disposition: inline;
	filename*0*="'This%20is%20broken";
z'This is brokenr	  r  s      r9   test_rfc2231_missing_tickz%TestRFC2231.test_rfc2231_missing_tick6  sO     '**	 	 	 	 	r;   c                     d}t          j        |          }|                     |                                d           d S )NzAContent-Disposition: inline;
	filename*0*="'This%20is%E2broken";
u   'This is�brokenr	  r  s      r9   0test_rfc2231_missing_tick_with_encoded_non_asciiz<TestRFC2231.test_rfc2231_missing_tick_with_encoded_non_ascii@  sO     '**"	$ 	$ 	$ 	$ 	$r;   c                     | j         }d}t          j        |          }|                    d          \  }}} ||d            ||d            ||d           d S )NzYContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'Frank's"; name*1*=" Document"

r&  rN   en-usr  r#  r  s          r9   !test_rfc2231_tick_attack_extendedz-TestRFC2231.test_rfc2231_tick_attack_extendedK  sx    
 '**"}}V441
7J
8W
1 !!!!!r;   c                     d}t          j        |          }|                    d          }|                     |t                     |                     |d           d S )NzWContent-Type: application/x-foo;
	name*0="us-ascii'en-us'Frank's"; name*1=" Document"

r&  zus-ascii'en-us'Frank's Documentr  r  s       r9   test_rfc2231_tick_attackz$TestRFC2231.test_rfc2231_tick_attackY  s_    
 '**f%%  ... ABBBBBr;   c                 ~    | j         }d}t          j        |          } ||                    d          d           d S )Nz:Content-Type: application/x-foo; name="Frank's Document"

r&  r  r#  r  s       r9   test_rfc2231_no_extended_valuesz+TestRFC2231.test_rfc2231_no_extended_valuese  sH     '**
3==  "455555r;   c                     | j         }d}t          j        |          }|                    d          \  }}} ||d            ||d            ||d           d S )NziContent-Type: application/x-foo;
	name*0*="us-ascii'en-us'My";
	name*1=" Document";
	name*2*=" For You"

r&  rN   r  My Document For Your#  r  s          r9   ,test_rfc2231_encoded_then_unencoded_segmentsz8TestRFC2231.test_rfc2231_encoded_then_unencoded_segmentso  x     '**"}}V441
7J
8W
1#$$$$$r;   c                     | j         }d}t          j        |          }|                    d          \  }}} ||d            ||d            ||d           d S )NziContent-Type: application/x-foo;
	name*0="us-ascii'en-us'My";
	name*1*=" Document";
	name*2*=" For You"

r&  rN   r  r!  r#  r  s          r9   ,test_rfc2231_unencoded_then_encoded_segmentsz8TestRFC2231.test_rfc2231_unencoded_then_encoded_segments  r#  r;   c                     ddg}|D ]D}|                      |          5  t          j        |          }d d d            n# 1 swxY w Y   Ed S )NzFrom: user@host.com
To: user@host.com
Bad-Header:
 =?us-ascii?Q?LCSwrV11+IB0rSbSker+M9vWR7wEDSuGqmHD89Gt=ea0nJFSaiz4vX3XMJPT4vrE?=
 =?us-ascii?Q?xGUZeOnp0o22pLBB7CYLH74Js=wOlK6Tfru2U47qR?=
 =?us-ascii?Q?72OfyEY2p2=2FrA9xNFyvH+fBTCmazxwzF8nGkK6D?=

Hello!
u  From: ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ <xxx@xxx>
To: "xxx" <xxx@xxx>
Subject:   ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½
MIME-Version: 1.0
Content-Type: text/plain; charset="windows-1251";
Content-Transfer-Encoding: 8bit

ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
)r   )r  r   r  )r6   messagesr   r8   s       r9   +test_should_not_hang_on_invalid_ew_messagesz7TestRFC2231.test_should_not_hang_on_invalid_ew_messages  s    "  	3 	3A"" 3 3/223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3s   A  A	A	N)!r  r  r  r$  r:  r  rE  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r%  r(  r{   r;   r9   r  r    s       K K K# # #JO O O  B2 2 2- - -- - - ] ] ]
F 
F 
F
F 
F 
FA A AO O O
F 
F 
FF F F
F 
F 
F: : :: : :
L 
L 
L; ; ;; ; ;" " "4 4 4  $ $ $" " "	C 	C 	C6 6 6% % %"% % %3 3 3 3 3r;   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )
TestSignedc                     t          |d          5 }|                                }t          j        |          }d d d            n# 1 swxY w Y   ||fS rI  rJ  )r6   rK  r   originalr8   s        r9   _msg_and_objzTestSigned._msg_and_obj  s    h111 	6RwwyyH+H55C	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 }s   )AAAc                    dd l } |j        d|j        |j        z            }|                    |                              d          }|                    |                              d          }|                     ||           d S )Nr   z^--([^\n]+)\n(.*?)\n--\1$r   )r  r  Sr  searchgroupr2   )r6   r,  resultr  repartinpartoutparts          r9   _signed_parts_eqzTestSigned._signed_parts_eq  s    			8"$+FFx((..q11--''--a00&)))))r;   c                     |                      d          \  }}|                                }|                     ||           d S r{  r-  r   r6  r6   r,  r8   r2  s       r9   test_long_headers_as_stringz&TestSigned.test_long_headers_as_string  sB    )),77#h/////r;   c                     |                      d          \  }}|                    d          }|                     ||           d S )Nr|  <   r{  r8  r9  s       r9   (test_long_headers_as_string_maxheaderlenz3TestSigned.test_long_headers_as_string_maxheaderlen  sH    )),77#B//h/////r;   c                     |                      d          \  }}t                      }t          |                              |           |                                }|                     ||           d S r{  )r-  r   r   r   r   r6  )r6   r,  r8   r   r2  s        r9   test_long_headers_flattenz$TestSigned.test_long_headers_flatten  se    )),77#ZZ"c"""h/////r;   N)r  r  r  r-  r6  r:  r=  r?  r{   r;   r9   r*  r*    s_          * * *0 0 0
0 0 0
0 0 0 0 0r;   r*  c                       e Zd Zd ZdS )TestHeaderRegistryc                     t                      } |dd          }|                     |j        d         t          j                   d S )NrG  zattachment; 0*00="foo"r   )r   r  r  r    InvalidHeaderDefect)r6   regr  s      r9   test_HeaderRegistryz&TestHeaderRegistry.test_HeaderRegistry  sE    C%'?@@ailF,FGGGGGr;   N)r  r  r  rE  r{   r;   r9   rA  rA    s(        H H H H Hr;   rA  __main__)fr  r9  rW   r,  r   warningsior   r   	itertoolsr   randomr   	threadingr   unittest.mockr	   r   email.policyemail.charsetr
   email.generatorr   r   r   email.headerr   r   r   email.headerregistryr   email.messager   email.mime.applicationr   email.mime.audior   email.mime.baser   email.mime.imager   email.mime.messager   email.mime.multipartr   email.mime.nonmultipartr   email.mime.textr   email.parserr   r   r   r   r    r!   r"   r#   test.supportr$   test.support.os_helperr%   test.test_emailr&   r'   r(   r)   r   r  rN  r.   TestCaser  r  r  r  r  r  r  r/  r  r  r  rA  rG  r  r  r  r  r  r  r  r  r  r  rv  r  r  r*  rA  r  mainr{   r;   r9   <module>ra     s  
 
			                                                   ! ! ! ! ! ! G G G G G G G G G G ; ; ; ; ; ; ; ; ; ; / / / / / / ! ! ! ! ! ! 2 2 2 2 2 2 & & & & & & $ $ $ $ $ $ & & & & & & * * * * * * . . . . . . 4 4 4 4 4 4 $ $ $ $ $ $ - - - - - - - -                                     ) ) ) ) ) ) ) ) ) ) ) ) 3 3 3 3 3 3 3 3 5 4 4 4 4 4 4 4	c c c c c] c c cN? ? ? ? ?8$ ? ? ?Fx> x> x> x> x>m x> x> x>zK/ K/ K/ K/ K/x( K/ K/ K/^/D /D /D /D /DH% /D /D /Dh7D 7D 7D 7D 7DH% 7D 7D 7DvXC XC XC XC XC(+ XC XC XCx7A 7A 7A 7A 7A8$ 7A 7A 7Ax~6 ~6 ~6 ~6 ~6M ~6 ~6 ~6BkK kK kK kK kK kK kK kK^}< }< }< }< }<- }< }< }<BsK sK sK sK sKm sK sK sKn		J 	J 	J 	J 	J} 	J 	J 	J"Z- Z- Z- Z- Z-] Z- Z- Z-~r> r> r> r> r> r> r> r>ld( d( d( d( d(M d( d( d(N-A -A -A -A -Am -A -A -A`QK QK QK QK QK- QK QK QKh[ [ [ [ [M [ [ [|- - - - - - - -$3 3 3 3 3%E$23 3 38 8 8 8 8'G'58 8 81D 1D 1D 1D 1D" 1D 1D 1Dh} } } } }" } } }D
5E 5E 5E 5E 5E(# 5E 5E 5Eta4 a4 a4 a4 a4 a4 a4 a4La3 a3 a3 a3 a3- a3 a3 a3N0 0 0 0 0 0 0 0BH H H H H H H H zHMOOOOO r;   