
    daf                       d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZm	Z	  G d de      Z
 G d d	      Z G d
 dee      Ze	 G d dee             Ze	 G d dee             Z G d de      Zedk(  r ej"                          yy)    N)_header_value_parser)errorspolicy)TestEmailBaseparameterizec                       e Zd Zd Zy)
TestTokensc                     t        j                  dd      }| j                  |d       | j                  t        |      d       | j                  |j                  d       | j                  |j
                  d       y )Nz 	fws )parserEWWhiteSpaceTerminalassertEqualstrvalue
token_type)selfxs     D/root/Python-3.12.4/Lib/test/test_email/test__header_value_parser.pytest_EWWhiteSpaceTerminalz$TestTokens.test_EWWhiteSpaceTerminal   s`    ''u5E"Q$"%u-    N)__name__
__module____qualname__r    r   r   r
   r
      s    .r   r
   c                   *    e Zd Z	 ddZ	 ddZ	 ddZy)TestParserMixinNc                    | j                  t        |      |       | j                  |j                  |       | j                  |j                  |       | j                  ||       || j                  |j
                  |       y y N)r   r   r   assertDefectsEqualall_defectscomments)r   tlreststringr   defects	remainderr#   s           r   _assert_resultszTestParserMixin._assert_results   sm    R&)5)8y)R[[(3  r   c           	      L     ||      \  }}	| j                  ||	||||d        |S )N)r#   r)   )
r   methodsourcer&   r   r'   r(   r#   r$   r%   s
             r   _test_get_xzTestParserMixin._test_get_x   s6    &>DRvugy&* 	 	,	r   c           	      D     ||      }| j                  |d|||d|       |S Nr   r+   )r   r,   inputr&   r   r'   r#   r$   s           r   _test_parse_xzTestParserMixin._test_parse_x&   s*    E]RVUGRJ	r   r    )r   r   r   r)   r.   r2   r   r   r   r   r      s      "&4 /3 '+r   r   c                   	   e Zd Z e edd            j                  d      Zej                  ej                  z   dz   Z
ej                  ej                  d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 Z%d Z&d Z'd  Z(d! Z)d" Z*d# Z+d$ Z,d% Z-d& Z.d' Z/d( Z0d) Z1d* Z2d+ Z3d, Z4d- Z5d. Z6d/ Z7d0 Z8d1 Z9d2 Z:d3 Z;d4 Z<d5 Z=d6 Z>d7 Z?d8 Z@d9 ZAd: ZBd; ZCd< ZDd= ZEd> ZFd? ZGd@ ZHdA ZIdB ZJdC ZKdD ZLdE ZMdF ZNdG ZOdH ZPdI ZQdJ ZRdK ZSdL ZTdM ZUdN ZVdO ZWdP ZXdQ ZYdR ZZdS Z[dT Z\dU Z]dV Z^dW Z_dX Z`dY ZadZ Zbd[ Zcd\ Zdd] Zed^ Zfd_ Zgd` Zhda Zidb Zjdc Zkdd Zlde Zmdf Zndg Zodh Zpdi Zqdj Zrdk Zsdl Ztdm Zudn Zvdo Zwdp Zxdq Zydr Zzds Z{dt Z|du Z}dv Z~dw Zdx Zdy Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdÄ ZdĄ Zdń ZdƄ ZdǄ ZdȄ ZdɄ Zdʄ Zd˄ Zd̄ Zd̈́ Zd΄ Zdτ ZdЄ Zdф Zd҄ Zdӄ ZdԄ ZdՄ Zdք Zdׄ Zd؄ Zdل Zdڄ Zdۄ Zd܄ Zd݄ Zdބ Zd߄ Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd 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' Z/d( Z0d) Z1d* Z2d+ Z3d, Z4d- Z5d. Z6d/ Z7d0 Z8d1 Z9d2 Z:d3 Z;d4 Z<d5 Z=d6 Z>d7 Z?d8 Z@d9 ZAd: ZBd; ZCd< ZDd= ZEd> ZFd? ZGd@ ZHdA ZIdB ZJdC ZKdD ZLdE ZMdF ZNdG ZOdH ZPdI ZQdJ ZRyK(L  
TestParser!      asciiz!#$%&'*+-/=?^_`{}|~r   z\[]c                 R    | j                  t        j                  dd      dg       y )Nfoo   r   r   _wsp_splitterr   s    r   test__wsp_splitter_one_wordz&TestParser.test__wsp_splitter_one_word6   s!    --eQ7%Ar   c                 T    | j                  t        j                  dd      g d       y )Nzfoo defr:   )r9    defr;   r=   s    r   test__wsp_splitter_two_wordsz'TestParser.test__wsp_splitter_two_words9   s#    --i;/B	Dr   c                 T    | j                  t        j                  dd      g d       y )Nzfoo 	 def jikr:   )r9    	 zdef jikr;   r=   s    r   test__wsp_splitter_ws_runsz%TestParser.test__wsp_splitter_ws_runs=   s$    --.>B.H	Jr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz 	  r@   r   r   )r.   r   get_fwsr   r   )r   r   s     r   test_get_fws_onlyzTestParser.test_get_fws_onlyD   s4    v~~wb"M/r   c                 L    | j                  t        j                  dddg d       y )N foor@   r9   r.   r   rG   r=   s    r   test_get_fws_spacezTestParser.test_get_fws_spaceH   s    c2uEr   c                 L    | j                  t        j                  dddg d       y )Nz 	 foo rD   r@   foo rK   r=   s    r   test_get_fws_ws_runzTestParser.test_get_fws_ws_runK   s    VS"fMr   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)NabcassertRaisesr   HeaderParseErrorr   get_encoded_wordr=   s    r   *test_get_encoded_word_missing_start_raisesz5TestParser.test_get_encoded_word_missing_start_raisesP   s9    v667 	+##E*	+ 	+ 	+	   ?Ac                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz=?abcrR   r=   s    r   (test_get_encoded_word_missing_end_raisesz3TestParser.test_get_encoded_word_missing_end_raisesT   s9    v667 	-##G,	- 	- 	-rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz=?abc?=rR   r=   s    r   +test_get_encoded_word_missing_middle_raisesz6TestParser.test_get_encoded_word_missing_middle_raisesX   s9    v667 	/##I.	/ 	/ 	/rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz=?utf-8?X?somevalue?=rR   r=   s    r   !test_get_encoded_word_invalid_ctez,TestParser.test_get_encoded_word_invalid_cte\   s:    v667 	=##$;<	= 	= 	=rW   c                 L    | j                  t        j                  dddg d       y )Nz#=?us-ascii?q?this_is_a_test?=  birdthis is a test  birdr.   r   rU   r=   s    r   test_get_encoded_word_valid_ewz)TestParser.test_get_encoded_word_valid_ew`   s'    00>))!	#r   c                 j    | j                  t        j                  dddt        j                  gd       y )Nz#=?us-ascii?q?this is a test?=  birdr_   r`   r.   r   rU   r   InvalidHeaderDefectr=   s    r   %test_get_encoded_word_internal_spacesz0TestParser.test_get_encoded_word_internal_spacesh   s0    00>)) 445!	#r   c                 L    | j                  t        j                  dddg d       y )Nz(=?us-ascii?q?first?=  =?utf-8?q?second?=firstz  =?utf-8?q?second?=ra   r=   s    r    test_get_encoded_word_gets_firstz+TestParser.test_get_encoded_word_gets_firstp   s'    00C  /	1r   c                 j    | j                  t        j                  dddt        j                  gd       y )Nz&=?us-ascii?q?first?==?utf-8?q?second?=rh   z=?utf-8?q?second?=rd   r=   s    r   1test_get_encoded_word_gets_first_even_if_no_spacez<TestParser.test_get_encoded_word_gets_first_even_if_no_spacex   s0    00A   445-	/r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz =?us-ascii*jive?q?first_second?=first secondr   us-asciijiver.   r   rU   r   charsetlangr   ews     r   +test_get_encoded_word_sets_extra_attributesz6TestParser.test_get_encoded_word_sets_extra_attributes   sS    f55;'' 	Z0&)r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz=?us-ascii?q?first_second?=rm   r   rn   rp   rs   s     r   +test_get_encoded_word_lang_default_is_blankz6TestParser.test_get_encoded_word_lang_default_is_blank   sS    f556'' 	Z0"%r   c                 j    | j                  t        j                  dddt        j                  gd       y )Nz=?us-ascii?q?firstsecond?=zfirstsecondr   )r.   r   rU   r   NonPrintableDefectr=   s    r   *test_get_encoded_word_non_printable_defectz5TestParser.test_get_encoded_word_non_printable_defect   s0    009** 334	r   c                 L    | j                  t        j                  dddg d       y )Nz=?us-ascii?q?=20foo?=rJ   r   ra   r=   s    r   ,test_get_encoded_word_leading_internal_spacez7TestParser.test_get_encoded_word_leading_internal_space   s'    00/	r   c                 L    | j                  t        j                  dddg d       y )Nz=?utf-8?q?=C3=89ric?=   Éricr   ra   r=   s    r   3test_get_encoded_word_quopri_utf_escape_follows_ctez>TestParser.test_get_encoded_word_quopri_utf_escape_follows_cte   s'    00/	r   c                 4    t        j                  |      }|dfS r0   )r   get_unstructured)r   r   tokens      r   	_get_unstzTestParser._get_unst   s    ''.byr   c                 D    | j                  | j                  dddg d       y r0   r.   r   r=   s    r   test_get_unstructured_nullz%TestParser.test_get_unstructured_null   s    RR<r   c                 D    | j                  | j                  dddg d       y Nr9   r   r   r=   s    r   test_get_unstructured_one_wordz)TestParser.test_get_unstructured_one_word   s    ub"Er   c                 D    | j                  | j                  dddg d       y )Nfoo bar birdr   r   r=   s    r   #test_get_unstructured_normal_phrasez.TestParser.test_get_unstructured_normal_phrase   s$    )7)7)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nzfoo 	 bar      birdr   r   r   r=   s    r   3test_get_unstructured_normal_phrase_with_whitespacez>TestParser.test_get_unstructured_normal_phrase_with_whitespace   s%    )?)?)7)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nz	  foo barz foo barr   r   r=   s    r   (test_get_unstructured_leading_whitespacez3TestParser.test_get_unstructured_leading_whitespace   $    )4)3)+)+		-r   c                 D    | j                  | j                  dddg d       y )N	foo bar  zfoo bar r   r   r=   s    r   )test_get_unstructured_trailing_whitespacez4TestParser.test_get_unstructured_trailing_whitespace   r   r   c                 D    | j                  | j                  dddg d       y )Nz  foo bar  z	 foo bar r   r   r=   s    r   5test_get_unstructured_leading_and_trailing_whitespacez@TestParser.test_get_unstructured_leading_and_trailing_whitespace   s$    )6)4)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nz=?us-ascii?q?bar?=barr   r   r=   s    r   (test_get_unstructured_one_valid_ew_no_wsz3TestParser.test_get_unstructured_one_valid_ew_no_ws   s%    )=).).)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nz=?us-ascii?q?bar?=  bar  bar r   r   r=   s    r   (test_get_unstructured_one_ew_trailing_wsz3TestParser.test_get_unstructured_one_ew_trailing_ws   s%    )?)0)/)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nz=?us-ascii?q?bar?= birdzbar birdr   r   r=   s    r   0test_get_unstructured_one_valid_ew_trailing_textz;TestParser.test_get_unstructured_one_valid_ew_trailing_text   s%    )B)3)3)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nzfoo =?us-ascii?q?bar?= birdr   r   r   r=   s    r   6test_get_unstructured_phrase_with_ew_in_middle_of_textzATestParser.test_get_unstructured_phrase_with_ew_in_middle_of_text   s%    )F)7)7)+)+		-r   c                 D    | j                  | j                  dddg d       y )Nz*foo =?us-ascii?q?bar?= =?us-ascii?q?bird?=foo barbirdr   r   r=   s    r   (test_get_unstructured_phrase_with_two_ewz3TestParser.test_get_unstructured_phrase_with_two_ew   s%    8	r   c                 D    | j                  | j                  dddg d       y )Nz-foo =?us-ascii?q?bar?= =?us-ascii?q?bird?=   zfoo barbird   zfoo barbird r   r   r=   s    r   4test_get_unstructured_phrase_with_two_ew_trailing_wsz?TestParser.test_get_unstructured_phrase_with_two_ew_trailing_ws   s%    ;	r   c                 D    | j                  | j                  dddg d       y )Nz  =?us-ascii?q?bar?=z  bar barr   r   r=   s    r   4test_get_unstructured_phrase_with_ew_with_leading_wsz?TestParser.test_get_unstructured_phrase_with_ew_with_leading_ws  s%    "	r   c                 D    | j                  | j                  dddg d       y )Nz-foo =?us-ascii?q?bar?= 	  =?us-ascii?q?bird?=r   r   r   r=   s    r   1test_get_unstructured_phrase_with_two_ew_extra_wsz<TestParser.test_get_unstructured_phrase_with_two_ew_extra_ws  s%    <	r   c                 D    | j                  | j                  dddg d       y )Nz-=?us-ascii?q?test?=   =?us-ascii?q?foo?=  valztestfoo  valztestfoo valr   r   r=   s    r   3test_get_unstructured_two_ew_extra_ws_trailing_textz>TestParser.test_get_unstructured_two_ew_extra_ws_trailing_text  s%    ;	r   c                 D    | j                  | j                  dddg d       y )Nz=?iso-8859-1?q?hello=20world?=zhello worldr   r   r=   s    r   )test_get_unstructured_ew_with_internal_wsz4TestParser.test_get_unstructured_ew_with_internal_ws   s%    ,	r   c                 D    | j                  | j                  dddg d       y )Nz6   =?us-ascii?q?=20test?=   =?us-ascii?q?=20foo?=  valz    test foo  valz  test foo valr   r   r=   s    r   1test_get_unstructured_ew_with_internal_leading_wsz<TestParser.test_get_unstructured_ew_with_internal_leading_ws(  s%    D	r   c                 D    | j                  | j                  dddg d       y )Nz
=?test valr   r   r=   s    r    test_get_unstructured_invalid_ewz+TestParser.test_get_unstructured_invalid_ew0  s%    	r   c                     | j                  | j                  dj                  dd      ddt        j                  gd       y )Ns   test foo  valr7   surrogateescapeu   test foo  valu   test foo valr   r.   r   decoder   UndecodableBytesDefectr=   s    r   'test_get_unstructured_undecodable_bytesz2TestParser.test_get_unstructured_undecodable_bytes8  s<     ''1BC! **+	r   c                     | j                  | j                  dj                  dd      ddt        j                  gdz  d       y )Ns4   =?us-ascii?q?=20test?=   =?us-ascii?q?=20foo?=  valr7   r   u    test foo  valu    test foo val   r   r   r=   s    r   -test_get_unstructured_undecodable_bytes_in_EWz8TestParser.test_get_unstructured_undecodable_bytes_in_EW@  sB     &*;<"!**+A-	r   c                 b    | j                  | j                  dddt        j                  gd       y )Nz=?utf-8?b?dmk?=vir   )r.   r   r   InvalidBase64PaddingDefectr=   s    r   ,test_get_unstructured_missing_base64_paddingz7TestParser.test_get_unstructured_missing_base64_paddingI  s.    ../	r   c                 b    | j                  | j                  dddt        j                  gd       y )Nz=?utf-8?b?dmk===?=r   r   )r.   r   r   InvalidBase64CharactersDefectr=   s    r   .test_get_unstructured_invalid_base64_characterz9TestParser.test_get_unstructured_invalid_base64_characterQ  s.    $112	r   c                     | j                  | j                  dddt        j                  t        j                  gd       y )Nz=?utf-8?b?dmk?=r   r   )r.   r   r   r   r   r=   s    r   >test_get_unstructured_invalid_base64_character_and_bad_paddingzITestParser.test_get_unstructured_invalid_base64_character_and_bad_paddingY  s9    !11..0	r   c                 b    | j                  | j                  dddt        j                  gd       y )Nz=?utf-8?b?abcde?=abcder   )r.   r   r   InvalidBase64LengthDefectr=   s    r   +test_get_unstructured_invalid_base64_lengthz6TestParser.test_get_unstructured_invalid_base64_lengthb  s.    --.	r   c                     | j                  | j                  dddt        j                  t        j                  gd       y )Nz=?utf-8?q?foo?==?utf-8?q?bar?=foobarr   r.   r   r   re   r=   s    r   /test_get_unstructured_no_whitespace_between_ewsz:TestParser.test_get_unstructured_no_whitespace_between_ewsk  s9    ,''&&(	r   c                 b    | j                  | j                  dddt        j                  gd       y )Nz!nowhitespace=?utf-8?q?somevalue?=nowhitespacesomevaluer   r   r=   s    r   3test_get_unstructured_ew_without_leading_whitespacez>TestParser.test_get_unstructured_ew_without_leading_whitespacet  /    NN/##''(	r   c                 b    | j                  | j                  dddt        j                  gd       y )Nz!=?utf-8?q?somevalue?=nowhitespacesomevaluenowhitespacer   r   r=   s    r   4test_get_unstructured_ew_without_trailing_whitespacez?TestParser.test_get_unstructured_ew_without_trailing_whitespace}  r   r   c                 b    | j                  | j                  dddt        j                  gd       y )Nz=?utf-8?q?somevalue?=aasomevalueaar   r   r=   s    r   ;test_get_unstructured_without_trailing_whitespace_hang_casezFTestParser.test_get_unstructured_without_trailing_whitespace_hang_case  s.    %''(	r   c                 D    | j                  | j                  dddg d       y )Nz=?utf-8?q?=somevalue?=r   r   r=   s    r   !test_get_unstructured_invalid_ew2z,TestParser.test_get_unstructured_invalid_ew2  %    $$$	r   c                 D    | j                  | j                  dddg d       y )Nz=?utf-8?X?=somevalue?=r   r   r=   s    r   $test_get_unstructured_invalid_ew_ctez/TestParser.test_get_unstructured_invalid_ew_cte  r   r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nr   r@   r   ptext)r.   r   get_qp_ctextr   r   r   r   s     r   test_get_qp_ctext_onlyz!TestParser.test_get_qp_ctext_only  s<      !4!4 ((CRA))73r   c                     | j                   j                  dd      }|j                  dd      }|j                  dd      }| j                  t        j                  || j                   dg d      }y )	N\\\(z\()z\)r@   r   )rfc_printable_asciireplacer.   r   r   r   with_qpr   s      r    test_get_qp_ctext_all_printablesz+TestParser.test_get_qp_ctext_all_printables  sf    **224@##C///#u-  !4!4!($*B*BCRQr   c                 L    | j                  t        j                  dddg d       y )Nfoo der9   r@    der.   r   r   r=   s    r   &test_get_qp_ctext_two_words_gets_firstz1TestParser.test_get_qp_ctext_two_words_gets_first  #    ,, %b%	9r   c                 L    | j                  t        j                  dddg d       y )Nfoo 		der9   r@    		der   r=   s    r   )test_get_qp_ctext_following_wsp_preservedz4TestParser.test_get_qp_ctext_following_wsp_preserved  s$    ,,$eS"i	Ar   c                 L    | j                  t        j                  dddg d       y )Nzfoo)r9   r@   r   r   r=   s    r   (test_get_qp_ctext_up_to_close_paren_onlyz3TestParser.test_get_qp_ctext_up_to_close_paren_only  #    ,,sB	5r   c                 L    | j                  t        j                  dddg d       y )Nzfoo  )r9   r@   z  )r   r=   s    r   2test_get_qp_ctext_wsp_before_close_paren_preservedz=TestParser.test_get_qp_ctext_wsp_before_close_paren_preserved  r   r   c                 L    | j                  t        j                  dddg d       y )Nzfoo)barr9   r@   z)barr   r=   s    r   &test_get_qp_ctext_close_paren_mid_wordz1TestParser.test_get_qp_ctext_close_paren_mid_word  #    ,,!5#r6	;r   c                 L    | j                  t        j                  dddg d       y )Nzfoo(r9   r@   r   r   r=   s    r   'test_get_qp_ctext_up_to_open_paren_onlyz2TestParser.test_get_qp_ctext_up_to_open_paren_only  r   r   c                 L    | j                  t        j                  dddg d       y )Nzfoo  (r9   r@   z  (r   r=   s    r   1test_get_qp_ctext_wsp_before_open_paren_preservedz<TestParser.test_get_qp_ctext_wsp_before_open_paren_preserved  r   r   c                 L    | j                  t        j                  dddg d       y )Nzfoo(barr9   r@   z(barr   r=   s    r   %test_get_qp_ctext_open_paren_mid_wordz0TestParser.test_get_qp_ctext_open_paren_mid_word  r   r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d   j                  d   d       y )Nzfoo bar)foo barr@   r   r    )r.   r   r   r   ry   r   r'   non_printablesr   s     r    test_get_qp_ctext_non_printablesz+TestParser.test_get_qp_ctext_non_printables  sV      !4!4 -|S!'!:!: ;SB 	q)88;VDr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y Nr   r   r   )r.   r   get_qcontentr   r   r   s     r   test_get_qcontent_onlyz!TestParser.test_get_qcontent_only  s<      !4!4 ((Hb"F))73r   c                     | j                   j                  dd      }|j                  dd      }| j                  t        j                  || j                   | j                   g d      }y )Nr   r   "z\"r   )r   r   r.   r   r  r   s      r    test_get_qcontent_all_printablesz+TestParser.test_get_qcontent_all_printables  s]    **224@##C/  !4!4g!%!9!9!%!9!92rCr   c                 L    | j                  t        j                  dddg d       y )Nr   r9   r   r.   r   r  r=   s    r   &test_get_qcontent_two_words_gets_firstz1TestParser.test_get_qcontent_two_words_gets_first  #    ,, %E	;r   c                 L    | j                  t        j                  dddg d       y )Nr   r9   r   r  r=   s    r   )test_get_qcontent_following_wsp_preservedz4TestParser.test_get_qcontent_following_wsp_preserved  s$    ,,$eUB		Cr   c                 L    | j                  t        j                  dddg d       y )Nfoo"r9   r  r  r=   s    r   #test_get_qcontent_up_to_dquote_onlyz.TestParser.test_get_qcontent_up_to_dquote_only  s#    ,,ub#	7r   c                 L    | j                  t        j                  dddg d       y )Nzfoo  "r9   z  "r  r=   s    r   2test_get_qcontent_wsp_before_close_paren_preservedz=TestParser.test_get_qcontent_wsp_before_close_paren_preserved  r  r   c                 L    | j                  t        j                  dddg d       y )Nzfoo"barr9   z"barr  r=   s    r   &test_get_qcontent_close_paren_mid_wordz1TestParser.test_get_qcontent_close_paren_mid_word  s#    ,,!5%V	=r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d   j                  d   d       y )Nzfoo fg"zfoo fgr  r   r  )r.   r   r  r   ry   r   r'   r  r   s     r    test_get_qcontent_non_printablesz+TestParser.test_get_qcontent_non_printables  sV      !4!4 ,k;!'!:!: ;SB 	q)88;VDr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nr   r   atext)r.   r   	get_atextr   r   r   r   s     r   test_get_atext_onlyzTestParser.test_get_atext_only  <      !1!1 ((Hb"F))73r   c                     | j                  t        j                  | j                  | j                  | j                  g d      }y r0   )r.   r   r!  rfc_atext_charsr"  s     r   test_get_atext_all_atextz#TestParser.test_get_atext_all_atext  8      !1!143G3G!%!5!5!%!5!5r2?r   c                 L    | j                  t        j                  dddg d       y Nfoo barr9   r   r.   r   r!  r=   s    r   #test_get_atext_two_words_gets_firstz.TestParser.test_get_atext_two_words_gets_first  #    ))!5%V	=r   c                 L    | j                  t        j                  dddg d       y Nz	foo 		barr9   z 		barr,  r=   s    r   &test_get_atext_following_wsp_preservedz1TestParser.test_get_atext_following_wsp_preserved
  $    ))%ueR	Er   c                 L    | j                  t        j                  dddg d       y Nzfoo@barr9   z@barr,  r=   s    r   test_get_atext_up_to_specialz'TestParser.test_get_atext_up_to_special  r.  r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d   j                  d   d       y )Nzfoo bar(r  r   r   r  )r.   r   r!  r   ry   r   r'   r  r"  s     r   test_get_atext_non_printablesz(TestParser.test_get_atext_non_printables  V      !1!1 -|\!'!:!: ;SB 	q)88;VDr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )N"foo"r9   r   bare-quoted-string)r.   r   get_bare_quoted_stringr   r   )r   bqss     r    test_get_bare_quoted_string_onlyz+TestParser.test_get_bare_quoted_string_only  s;    v<<&B@)=>r   c                 (   | j                  t        j                        5  t        j                  d       d d d        | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   GxY w# 1 sw Y   y xY w)Nr  z  "foo")rS   r   rT   r   r<  r=   s    r   2test_get_bare_quoted_string_must_start_with_dquotez=TestParser.test_get_bare_quoted_string_must_start_with_dquote  su    v667 	2))&1	2v667 	5)))4	5 	5	2 	2	5 	5   A<B<BBc                 L    | j                  t        j                  dddg d       y N""r   r.   r   r<  r=   s    r   'test_get_bare_quoted_string_only_quotesz2TestParser.test_get_bare_quoted_string_only_quotes%  s#    66tRR	1r   c                 j    | j                  t        j                  dddt        j                  gd       y )Nr  rD  r   r.   r   r<  r   re   r=   s    r   -test_get_bare_quoted_string_missing_endquotesz8TestParser.test_get_bare_quoted_string_missing_endquotes)  s-    66dB)C)C(Db	Jr   c                 L    | j                  t        j                  dddg d       y )Nz
"foo"	 barr:  r9   z	 barrE  r=   s    r   3test_get_bare_quoted_string_following_wsp_preservedz>TestParser.test_get_bare_quoted_string_following_wsp_preserved-  s#    66GUB	:r   c                 L    | j                  t        j                  dddg d       y )Nz"foo bar moo"zfoo bar moor   rE  r=   s    r   *test_get_bare_quoted_string_multiple_wordsz5TestParser.test_get_bare_quoted_string_multiple_words1  $    66o}b"	Fr   c                 L    | j                  t        j                  dddg d       y )Nz" foo  moo	"z
 foo  moo	r   rE  r=   s    r   8test_get_bare_quoted_string_multiple_words_wsp_preservedzCTestParser.test_get_bare_quoted_string_multiple_words_wsp_preserved5  rN  r   c                 L    | j                  t        j                  dddg d       y )Nz"foo"barr:  r9   r   rE  r=   s    r   /test_get_bare_quoted_string_end_dquote_mid_wordz:TestParser.test_get_bare_quoted_string_end_dquote_mid_word9  s#    66%U	4r   c                 L    | j                  t        j                  dddg d       y )Nz
"foo\"in"az	"foo\"in"zfoo"inarE  r=   s    r   )test_get_bare_quoted_string_quoted_dquotez4TestParser.test_get_bare_quoted_string_quoted_dquote=  s#    66L(B	=r   c                 j    | j                  t        j                  dddt        j                  gd       y )Nz"aa"zaar   )r.   r   r<  r   ry   r=   s    r   *test_get_bare_quoted_string_non_printablesz5TestParser.test_get_bare_quoted_string_non_printablesA  s-    66X''("	.r   c                     | j                  t        j                  dddt        j                  gd       | j                  t        j                  dddt        j                  gd       y )Nz"foor:  r9   r   z"foo z"foo "rN   rH  r=   s    r   )test_get_bare_quoted_string_no_end_dquotez4TestParser.test_get_bare_quoted_string_no_end_dquoteF  sZ    66We(()2	/ 	66h(()2	/r   c                 L    | j                  t        j                  dddg d       y rC  rE  r=   s    r   (test_get_bare_quoted_string_empty_quotesz3TestParser.test_get_bare_quoted_string_empty_quotesN  s#    66$B	$r   c                     | j                  t        j                  dddt        j                  t        j                  gd       y )Nz"=?utf-8?Q?not_really_valid?="z"not really valid"znot really validr   rH  r=   s    r   test_encoded_word_inside_quotesz*TestParser.test_encoded_word_inside_quotesS  s;    66, '''')	r   c           	          | j                  t        j                  dddg ddg      }| j                  |j                  d       y )N	(comment)r@   r   comment)r.   r   get_commentr   r   r   r`  s     r   test_get_comment_onlyz TestParser.test_get_comment_only^  s@    ""6#5#5c2rI;@++Y7r   c                 (   | j                  t        j                        5  t        j                  d       d d d        | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   GxY w# 1 sw Y   y xY w)Nr  z  (foo")rS   r   rT   r   ra  r=   s    r   &test_get_comment_must_start_with_parenz1TestParser.test_get_comment_must_start_with_parenc  su    v667 	'v&	'v667 	*y)	* 	*	' 	'	* 	*rA  c           	      P    | j                  t        j                  dddg ddg       y )Nz(comment)  	r_  r@     	r`  r.   r   ra  r=   s    r   (test_get_comment_following_wsp_preservedz3TestParser.test_get_comment_following_wsp_preservedi  (    ++[#r6I;	Hr   c           	      P    | j                  t        j                  dddg ddg       y )Nz(foo bar)  		(foo bar)r@   rg  r+  rh  r=   s    r   test_get_comment_multiple_wordsz*TestParser.test_get_comment_multiple_wordsm  rj  r   c           	      P    | j                  t        j                  dddg ddg       y )Nz( foo  bar	 )  	z( foo  bar	 )r@   rg  z foo  bar	 rh  r=   s    r   -test_get_comment_multiple_words_wsp_preservedz8TestParser.test_get_comment_multiple_words_wsp_preservedq  s*    ++ "2CV 	"r   c           	      P    | j                  t        j                  dddg ddg       y )Nz(foo)bar(foo)r@   r   r9   rh  r=   s    r   #test_get_comment_end_paren_mid_wordz.TestParser.test_get_comment_end_paren_mid_wordv  s'    ++b%%	:r   c           	      P    | j                  t        j                  dddg ddg       y )Nz(foo\) \(\)bar)r@   r   z
foo) ()barrh  r=   s    r   test_get_comment_quoted_parensz)TestParser.test_get_comment_quoted_parensz  s)    ++ 2CR,	Qr   c           	      n    | j                  t        j                  dddt        j                  gddg       y )Nz	(foobar)r@   r   zfoobar)r.   r   ra  r   ry   r=   s    r   test_get_comment_non_printablez)TestParser.test_get_comment_non_printable~  s1    ++NC&&'l^	=r   c           	          | j                  t        j                  dddt        j                  gddg       | j                  t        j                  dddt        j                  gddg       y )	Nz(foo barrl  r@   r   r+  z
(foo bar  z(foo bar  )r   r.   r   ra  r   re   r=   s    r   test_get_comment_no_end_parenz(TestParser.test_get_comment_no_end_paren  sb    ++S''("yk	; 	++-''("{m	=r   c           	          | j                  t        j                  dddg ddg      }| j                  |d   j                  d       y )Nz
(foo(bar))r@   r   zfoo(bar)r:   r   r.   r   ra  r   contentrb  s     r   test_get_comment_nested_commentz*TestParser.test_get_comment_nested_comment  sD    ""6#5#5,Rj\C++U3r   c           	          | j                  t        j                  dddg ddg      }| j                  |d   j                  d       y )Nz(foo ( bar ) )r@   r   zfoo ( bar ) r    bar r{  rb  s     r   #test_get_comment_nested_comment_wspz.TestParser.test_get_comment_nested_comment_wsp  sF    ""6#5#5.Rn=MO++W5r   c           	      P    | j                  t        j                  dddg ddg       y )Nz()r@   r   rh  r=   s    r   test_get_comment_empty_commentz)TestParser.test_get_comment_empty_comment  s'    ++$RbT	+r   c           	         | j                  t        j                  dddg ddg      }t        ddd      D ]8  }| j	                  |d   j
                  d|d	z
  z  d
z   d|d	z
  z  z          |d   }: | j	                  |j
                  d
       y )N(((((foo)))))r@   r   ((((foo))))   r   r   r:   r9   r   )r.   r   ra  ranger   r|  )r   r`  is      r   !test_get_comment_multiple_nestingz,TestParser.test_get_comment_multiple_nesting  s    ""6#5#5_c2rM?Lq!R 	!AWQZ//ac5ac1JKajG	! 	%0r   c           	      t    | j                  t        j                  dddt        j                  gdz  ddg       y )Nz(((((foo)))r  r@   r   r   r  rx  r=   s    r   'test_get_comment_missing_end_of_nestingz2TestParser.test_get_comment_missing_end_of_nesting  s7    ++?C''(*B	Ar   c           	          | j                  t        j                  dddg ddg      }| j                  |d   j                  d       y )Nz(foo (b\)))r@   r   z	foo (b\))r   zb)r{  rb  s     r   %test_get_comment_qs_in_nested_commentz0TestParser.test_get_comment_qs_in_nested_comment  sD    ""6#5#5NCR,I++T2r   c           	          | j                  t        j                  dddg dg       }| j                  |j                  d       y )Nz  	 	r@   r   cfws)r.   r   get_cfwsr   r   r   r  s     r   test_get_cfws_only_wsz TestParser.test_get_cfws_only_ws  s9    y#r2r3&1r   c           	          | j                  t        j                  dddg ddg      }| j                  |d   j                  d       y )Nrq  r@   r   r9   r   r.   r   r  r   r|  r  s     r   test_get_cfws_only_commentz%TestParser.test_get_cfws_only_comment  s?    Wc2rE74a%0r   c           
          | j                  t        j                  dddg dddg      }| j                  |d   j                  d       | j                  |d   j                  d       y )Nz (foo )  ( bar) r@   r   rN   r   r:      r  r  s     r   test_get_cfws_only_mixedz#TestParser.test_get_cfws_only_mixed  s^     2CR " 	a&1a&1r   c           	          | j                  t        j                  dddg ddg      }| j                  |d   j                  d       y )Nz	(foo) bar(foo) r@   r   r9   r   r  r  s     r    test_get_cfws_ends_at_non_leaderz+TestParser.test_get_cfws_ends_at_non_leader  s?    3EE7<a%0r   c           	          | j                  t        j                  dddg ddg      }| j                  |d   j                  d       y )Nz(foo) r  r@   r9   r   r  r  s     r   #test_get_cfws_ends_at_non_printablez.TestParser.test_get_cfws_ends_at_non_printable  s?    (CVeW>a%0r   c           	          | j                  t        j                  dddt        j                  gddg      }| j                  |d   j                  d       y )Nz(foo ) "test"z(foo ) r@   z"test"zfoo r   )r.   r   r  r   ry   r   r|  r  s     r   &test_get_cfws_non_printable_in_commentz1TestParser.test_get_cfws_non_printable_in_comment  sL    &&'J<A 	a*5r   c           	          | j                  t        j                  dddt        j                  gddg      }| j                  |d   j                  d       y )Nz  (foo z  (foo )r@   r   rN   r:   )r.   r   r  r   re   r   r|  r  s     r   $test_get_cfws_header_ends_in_commentz/TestParser.test_get_cfws_header_ends_in_comment  sK    z3''("vh8 	a&1r   c           
          | j                  t        j                  dddg dddg      }| j                  |d   j                  dg       | j                  |d   j                  dg       y )Nz(foo (bar)) ((a)(a))r@   r   z	foo (bar)z(a)(a)r   r   )r.   r   r  r   r#   r  s     r   &test_get_cfws_multiple_nested_commentsz1TestParser.test_get_cfws_multiple_nested_comments  sf    "$:C[(+- 	a))K=9a))H:6r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )Nz"bob"bobr   quoted-string)r.   r   get_quoted_stringr   r   quoted_valuer|  r   qss     r   test_get_quoted_string_onlyz&TestParser.test_get_quoted_string_only  sa    f66WeR-8'2U+r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz		 "bob"   bob r    "bob" r  )r.   r   r  r   r  r|  r  s     r   test_get_quoted_string_with_wspz*TestParser.test_get_quoted_string_with_wsp  sM    f66,R9)4U+r   c                 D   | j                  t        j                  dddg d      }| j                  |d   d   j                  d       | j                  |d   d   j                  d       | j                  |j                  d	       | j                  |j
                  d
       y )Nz (foo) "bob"(bar)r  r   r   r:   r9   r   r   r  r  r.   r   r  r   r|  r  r  s     r   ,test_get_quoted_string_with_comments_and_wspz7TestParser.test_get_quoted_string_with_comments_and_wsp  s    f66!4gr2GAq))51Aq))51U+)4r   c                 >   | j                  t        j                  dddg d      }| j                  |d   j                  ddg       | j                  |d   j                  dg       | j                  |j
                  d	       | j                  |j                  d
       y )Nz (foo) (bar) "bob"(bird)r  r   r   r9   r   r   birdr  r  r.   r   r  r   r#   r|  r  r  s     r   -test_get_quoted_string_with_multiple_commentsz8TestParser.test_get_quoted_string_with_multiple_comments  s    f66&(BGB 	A%8A&2U+)4r   c                    | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       | j                  |j                  d       | j                  |j                  d       y )Nz
 (
) "bob" bobr   r   
r   "bob"	r.   r   r  r   ry   r   r#   r|  r  r  s     r   /test_get_quoted_string_non_printable_in_commentz:TestParser.test_get_quoted_string_non_printable_in_comment  ss    f66_f**+R1 	A&2U+(3r   c                    | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       | j                  |j                  d       | j                  |j                  d       y )Nz	 (a) "a" ar   r   rT  zaz "a"r  r  s     r   0test_get_quoted_string_non_printable_in_qcontentz;TestParser.test_get_quoted_string_non_printable_in_qcontent  ss    f66NH**+R1 	A#/W-*5r   c                     | j                  t        j                  dddg d      }| j                  |d   j                  dg       | j                  |j
                  d       | j                  |j                  d       y )Nz (a) "foo  bar "z
 foo  bar r   r   rT  z	foo  bar z "foo  bar "r  r  s     r   "test_get_quoted_string_internal_wsz-TestParser.test_get_quoted_string_internal_ws  sk    f66 2LB 	A#/[1.9r   c                 Z   | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       | j                  |d   j                  dg       | j                  |j                  d       | j                  |j                  d	       y )
Nz (a) "bob" (az (a) "bob" (a)r  r   r   rT  r   r  r  	r.   r   r  r   re   r   r#   r|  r  r  s     r   -test_get_quoted_string_header_ends_in_commentz8TestParser.test_get_quoted_string_header_ends_in_comment  s    f66-w++,b2 	A#/A#/U+)4r   c                    | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       | j                  |j                  d       | j                  |j                  d       y )	Nz	 (a) "bobz
 (a) "bob"r  r   r   rT  r  r  r  r  s     r   .test_get_quoted_string_header_ends_in_qcontentz9TestParser.test_get_quoted_string_header_ends_in_qcontent  ss    f66v++,b2 	A#/U+(3r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wNz (foo) rS   r   rT   r   r  r=   s    r   'test_get_quoted_string_cfws_only_raisesz2TestParser.test_get_quoted_string_cfws_only_raises$  s9    v667 	0$$Y/	0 	0 	0rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz	 (ab) xyzr  r=   s    r   'test_get_quoted_string_no_quoted_stringz2TestParser.test_get_quoted_string_no_quoted_string(  s9    v667 	2$$[1	2 	2 	2rW   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz	 "bob" feez	 "bob" r  feer  r  r  r  s     r   )test_get_quoted_string_qs_ends_at_noncfwsz4TestParser.test_get_quoted_string_qs_ends_at_noncfws,  sM    f66K"e=U+)4r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nr  r   atom)r.   r   get_atomr   r   r   r  s     r   test_get_atom_onlyzTestParser.test_get_atom_only4  s7    5%R)&1r   c                 L    | j                  t        j                  dddg d       y )Nz	 bob  r  r   r.   r   r  r=   s    r   test_get_atom_with_wspz!TestParser.test_get_atom_with_wsp9  s!    
GR	5r   c                     | j                  t        j                  dddg d      }| j                  |d   d   j                  d       | j                  |d   d   j                  d       y )	Nz (foo) bob(bar)r  r   r   r:   r9   r   r   )r.   r   r  r   r|  r  s     r   #test_get_atom_with_comments_and_wspz.TestParser.test_get_atom_with_comments_and_wsp=  sa    0'2rCa++U3a++U3r   c                     | j                  t        j                  dddg d      }| j                  |d   j                  ddg       | j                  |d   j                  dg       y )	Nz (foo) (bar) bob(bird)r  r   r   r9   r   r   r  r.   r   r  r   r#   r  s     r   $test_get_atom_with_multiple_commentsz/TestParser.test_get_atom_with_multiple_commentsC  sa    $&>B 	a))E5>:a))F84r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       y )Nz (
) bobr  r   r   r  r.   r   r  r   ry   r   r#   r  s     r   &test_get_atom_non_printable_in_commentz1TestParser.test_get_atom_non_printable_in_commentJ  sK    =&**+R1 	a))F84r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       y )Nz (a) ar  r   r   rT  r  r  s     r   $test_get_atom_non_printable_in_atextz/TestParser.test_get_atom_non_printable_in_atextP  sK    ,**+R1 	a))C51r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |d   j                  dg       | j                  |d   j                  dg       y )Nz (a) bob (az (a) bob (a)r  r   r   rT  r   )r.   r   r  r   re   r   r#   r  s     r   $test_get_atom_header_ends_in_commentz/TestParser.test_get_atom_header_ends_in_commentV  sg    >7++,b2 	a))C51a))C51r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz (ab) rS   r   rT   r   r  r=   s    r   test_get_atom_no_atomz TestParser.test_get_atom_no_atom]  s7    v667 	&OOH%	& 	& 	&rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz (ab) @r  r=   s    r   $test_get_atom_no_atom_before_specialz/TestParser.test_get_atom_no_atom_before_speciala  s7    v667 	'OOI&	' 	' 	'rW   c                     | j                  t        j                  dddg d      }| j                  |d   j                  dg       | j                  |d   j                  dg       y )	Nz (foo) bob(bar)  @bangz (foo) bob(bar)  r  z@bangr   r9   r   r   r  r  s     r   "test_get_atom_atom_ends_at_specialz-TestParser.test_get_atom_atom_ends_at_speciale  s]    $&97BQa))E73a))E73r   c                 L    | j                  t        j                  dddg d       y )Nz	bob  fredzbob  zbob fredr  r=   s    r   "test_get_atom_atom_ends_at_noncfwsz-TestParser.test_get_atom_atom_ends_at_noncfwsk  s!    &"f	6r   c                 L    | j                  t        j                  dddg d       y Nz=?utf-8?q?=20bob?=r  r   r  r=   s    r   test_get_atom_rfc2047_atomz%TestParser.test_get_atom_rfc2047_atomo  s!     &&"b	:r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |      d       y )Nzfoo.bar.bangr   zdot-atom-text   )r.   r   get_dot_atom_textr   r   lenr   dot_atom_texts     r   test_get_dot_atom_textz!TestParser.test_get_dot_atom_textu  sQ    (()A)ANNBD11?C]+Q/r   c                 L    | j                  t        j                  dddg d      }y r   r.   r   r  r  s     r   )test_get_dot_atom_text_lone_atom_is_validz4TestParser.test_get_dot_atom_text_lone_atom_is_valid{  s%    (()A)A5%R)r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz.foo.barrS   r   rT   r   r  r=   s    r   ,test_get_dot_atom_text_raises_on_leading_dotz7TestParser.test_get_dot_atom_text_raises_on_leading_dot  9    v667 	1$$Z0	1 	1 	1rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nzfoo.bar.r  r=   s    r   -test_get_dot_atom_text_raises_on_trailing_dotz8TestParser.test_get_dot_atom_text_raises_on_trailing_dot  r   rW   c                    | j                  t        j                        5  t        j                  d       d d d        | j                  t        j                        5  t        j                  d       d d d        | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   y xY w)Nz foo.barz@foo.barz	"foo.bar"r  r=   s    r   2test_get_dot_atom_text_raises_on_leading_non_atextz=TestParser.test_get_dot_atom_text_raises_on_leading_non_atext  s    v667 	1$$Z0	1v667 	1$$Z0	1v667 	2$$[1	2 	2		1 	1	1 	1	2 	2#   B9CC9CCCc                 L    | j                  t        j                  dddg d      }y r4  r  r  s     r   .test_get_dot_atom_text_trailing_text_preservedz9TestParser.test_get_dot_atom_text_trailing_text_preserved  s%    (()A)AueR1r   c                 L    | j                  t        j                  dddg d      }y )Nzfoo .barr9   z .barr  r  s     r   ,test_get_dot_atom_text_trailing_ws_preservedz7TestParser.test_get_dot_atom_text_trailing_ws_preserved  s%    (()A)Aub'3r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |      d       y )Nzfoo.bar.bingr   zdot-atomr:   )r.   r   get_dot_atomr   r   r  )r   dot_atoms     r   test_get_dot_atom_onlyz!TestParser.test_get_dot_atom_only  sP    ##F$7$7NNBD,,j9X*r   c                 L    | j                  t        j                  dddg d       y )Nz	  foo.bar.bing   foo.bar.bing r   r.   r   r  r=   s    r   test_get_dot_atom_with_wspz%TestParser.test_get_dot_atom_with_wsp  s&    ,, "68H"b	Rr   c                 L    | j                  t        j                  dddg d       y )Nz (sing)  foo.bar.bing (here) r  r   r  r=   s    r   'test_get_dot_atom_with_comments_and_wspz2TestParser.test_get_dot_atom_with_comments_and_wsp  s%    ,,+-L "b	*r   c                 L    | j                  t        j                  dddg d       y )Nz (sing)  foo.bar .bing (here) z (sing)  foo.bar z	 foo.bar z.bing (here) r  r=   s    r   %test_get_dot_atom_space_ends_dot_atomz0TestParser.test_get_dot_atom_space_ends_dot_atom  s%    ,,,.AR	2r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr  rS   r   rT   r   r  r=   s    r    test_get_dot_atom_no_atom_raisesz+TestParser.test_get_dot_atom_no_atom_raises  s9    v667 	+	*	+ 	+ 	+rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz (foo) .barr  r=   s    r   $test_get_dot_atom_leading_dot_raisesz/TestParser.test_get_dot_atom_leading_dot_raises  s9    v667 	/.	/ 	/ 	/rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz	bar..bangr  r=   s    r   !test_get_dot_atom_two_dots_raisesz,TestParser.test_get_dot_atom_two_dots_raises  s9    v667 	-,	- 	- 	-rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz (foo) bar.bang. foor  r=   s    r   %test_get_dot_atom_trailing_dot_raisesz0TestParser.test_get_dot_atom_trailing_dot_raises  s:    v667 	8 67	8 	8 	8rW   c                 L    | j                  t        j                  dddg d       y r  r  r=   s    r   test_get_dot_atom_rfc2047_atomz)TestParser.test_get_dot_atom_rfc2047_atom  s#    ,, &&"b	:r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |d   j                  d       y )Nz (foo) bar (bang) :ahz (foo) bar (bang) r  z:ahr  r   r  )r.   r   get_wordr   r   r   words     r   test_get_word_atom_yields_atomz)TestParser.test_get_word_atom_yields_atom  sS    #%97BO&1a++V4r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(Recipients list suppressed)rS   r   rT   r   r"  r=   s    r   test_get_word_all_CFWSz!TestParser.test_get_word_all_CFWS  s:     v667 	;OO9:	; 	; 	;rW   c                 8   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |d   j                  d       | j                  |d   j
                  d       | j                  |j                  d       y )	Nz"bar " (bang) ahz"bar " (bang) r   ahr  r   r;  r   )r.   r   r"  r   r   r   r|  r#  s     r   test_get_word_qs_yields_qsz%TestParser.test_get_word_qs_yields_qs  s     0'2tE/:a++-ABa/v.r   c                 L    | j                  t        j                  dddg d       y )Nzfoo.r9   .)r.   r   r"  r=   s    r   test_get_word_ends_at_dotz$TestParser.test_get_word_ends_at_dot  s!    E5"c	+r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )N""Fred A. Johnson" is his name, oh."Fred A. Johnson" is his nameFred A. Johnson is his name, oh.phrase)r.   r   
get_phraser   r   r   r3  s     r   test_get_phrase_simplez!TestParser.test_get_phrase_simple  sA    !!&"3"30+) 	**H5r   c                     | j                  t        j                  dddg d      }| j                  |d   d   j                  dg       | j                  |d   d   j                  dg       y )	N. (A) bird (in (my|your)) "hand  " is messy	<>	+ (A) bird (in (my|your)) "hand  " is messy	z bird hand   is messy <>	r   Ar   in (my|your))r.   r   r4  r   r#   r5  s     r   test_get_phrase_complexz"TestParser.test_get_phrase_complex  sl    !!&"3"3>:$ 	1..61..0@Ar   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  t        |      d       | j                  |d   j                  dg       y )NFred A.(weird).O JohnsonFred A. .O Johnsonr  r      weirdr.   r   r4  r   ObsoleteHeaderDefectr   r  r#   r5  s     r   test_get_phrase_obsoletez#TestParser.test_get_phrase_obsolete  si    !!&"3"3&& (()!+ 	Va(++gY7r   c           	      
   | j                  t        j                  dddt        j                  gt        j
                  gdz  z   d      }| j                  t        |      d       | j                  |d   j                  dg       y )N(even weirder).namez .namer   r   r  r   even weirder)	r.   r   r4  r   re   rD  r   r  r#   r5  s     r   +test_get_phrase_pharse_must_start_with_wordz6TestParser.test_get_phrase_pharse_must_start_with_word  sx    !!&"3"3!!''(F,G,G+H+JJ 	Va(++n-=>r   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  t        |      d       | j                  |d   j                  dg       y )	N)simple phrase.(with trailing comment):boo%simple phrase.(with trailing comment)zsimple phrase. r   :boor  r  with trailing commentrC  r5  s     r   $test_get_phrase_ending_with_obsoletez/TestParser.test_get_phrase_ending_with_obsolete  sk    !!&"3"373(()!+ 	Va(++.E-FGr   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr  )rS   r   rT   r   r4  r=   s    r   get_phrase_cfws_only_raisesz&TestParser.get_phrase_cfws_only_raises  s9    v667 	)i(	) 	) 	)rW   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nzdinsdale@python.orgdinsdale@python.org
local-partr.   r   get_local_partr   r   
local_partr   rX  s     r   test_get_local_part_simplez%TestParser.test_get_local_part_simple  sR    %%f&;&;!:z2}N
..=..
;r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )NzFred.A.Johnson@python.orgFred.A.JohnsonrT  r.   r   rW  r   rX  rY  s     r   test_get_local_part_with_dotz'TestParser.test_get_local_part_with_dot  sB    %%f&;&;'
 	..0@Ar   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz Fred.A.Johnson  @python.orgz Fred.A.Johnson   Fred.A.Johnson rT  r\  r]  rY  s     r   #test_get_local_part_with_whitespacez.TestParser.test_get_local_part_with_whitespace#  sB    %%f&;&;*
 	..0@Ar   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |d   d   j
                  dg       | j                  |d   d   j
                  d	g       y )
Nz/ (foo) Fred.A.Johnson (bar (bird))  @python.orgz$ (foo) Fred.A.Johnson (bar (bird))  r`  rT  r\  r   r9   r   
bar (bird)r.   r   rW  r   rX  r#   rY  s     r   test_get_local_part_with_cfwsz(TestParser.test_get_local_part_with_cfws,  s    %%f&;&;=2
 	..0@AAq)22UG<Aq)22\NCr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz"dinsdale"@python.orgz
"dinsdale"rT  rU  rS  rV  rY  s     r   !test_get_local_part_simple_quotedz,TestParser.test_get_local_part_simple_quoted7  sR    %%f&;&;#\<]T
..=..
;r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz"Fred.A.Johnson"@python.orgz"Fred.A.Johnson"rT  r\  r]  rY  s     r   #test_get_local_part_with_quoted_dotz.TestParser.test_get_local_part_with_quoted_dot=  sB    %%f&;&;)
 	..0@Ar   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz "Fred A. Johnson"  @python.orgz "Fred A. Johnson"  z "Fred A. Johnson" rT  zFred A. Johnsonr]  rY  s     r   *test_get_local_part_quoted_with_whitespacez5TestParser.test_get_local_part_quoted_with_whitespaceF  sB    %%f&;&;-"!
 	..0ABr   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |d   d   j
                  dg       | j                  |d   d   j
                  d	g       y )
Nz4 (foo) " Fred A. Johnson " (bar (bird))  @python.orgz) (foo) " Fred A. Johnson " (bar (bird))  z " Fred A. Johnson " rT  z Fred A. Johnson r   r9   r   rc  rd  rY  s     r   $test_get_local_part_quoted_with_cfwsz/TestParser.test_get_local_part_quoted_with_cfwsO  s    %%f&;&;B7#
 	..0CDAq)22UG<Aq)22\NCr   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )NzFred. A.Johnson@python.orgzFred. A.JohnsonrT  r\  r.   r   rW  r   rD  r   rX  rY  s     r   #test_get_local_part_simple_obsoletez.TestParser.test_get_local_part_simple_obsolete[  sK    %%f&;&;((()
 	..0@Ar   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )NzA (foo )Fred (bar).(bird) A.(sheep)Johnson."and  dogs "@python.orgz6 (foo )Fred (bar).(bird) A.(sheep)Johnson."and  dogs "z Fred . A. Johnson.and  dogs rT  zFred.A.Johnson.and  dogs ro  rY  s     r   &test_get_local_part_complex_obsolete_1z1TestParser.test_get_local_part_complex_obsolete_1d  sK    %%f&;&;OD+(()
 	..0KLr   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz@ (foo )Fred (bar).(bird) A.(sheep)Johnson "and  dogs"@python.orgz5 (foo )Fred (bar).(bird) A.(sheep)Johnson "and  dogs"z Fred . A. Johnson and  dogsr   rT  zFred.A.Johnson and  dogsr.   r   rW  r   re   r   rX  rY  s     r   ,test_get_local_part_complex_obsolete_invalidz7TestParser.test_get_local_part_complex_obsolete_invalidm  sP    %%f&;&;NC*''(*
 	..0JKr   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr0   rS   r   rT   r   rW  r=   s    r    test_get_local_part_empty_raisesz+TestParser.test_get_local_part_empty_raisesv  9    v667 	&!!"%	& 	& 	&rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr  rw  r=   s    r   "test_get_local_part_no_part_raisesz-TestParser.test_get_local_part_no_part_raisesz  s9    v667 	-!!),	- 	- 	-rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz (foo) @python.orgrw  r=   s    r   *test_get_local_part_special_instead_raisesz5TestParser.test_get_local_part_special_instead_raises~  s:    v667 	8!!"67	8 	8 	8rW   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz borris.@python.orgz borris.r   rT  borris.rt  rY  s     r    test_get_local_part_trailing_dotz+TestParser.test_get_local_part_trailing_dot  O    %%f&;&;!''(*
 	..	:r   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz borris. @python.orgz	 borris. r   rT  r  rt  rY  s     r   (test_get_local_part_trailing_dot_with_wsz3TestParser.test_get_local_part_trailing_dot_with_ws  sO    %%f&;&;"''(*
 	..	:r   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz.borris@python.org.borrisr   rT  rt  rY  s     r   test_get_local_part_leading_dotz*TestParser.test_get_local_part_leading_dot  sO    %%f&;&; ''(*
 	..	:r   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz .borris@python.orgz .borrisr   rT  r  rt  rY  s     r   (test_get_local_part_leading_dot_after_wsz3TestParser.test_get_local_part_leading_dot_after_ws  r  r   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz  borris.(foo).natasha@python.orgz borris.(foo).natashaz borris. .natashar   rT  zborris..natashart  rY  s     r   %test_get_local_part_double_dot_raisesz0TestParser.test_get_local_part_double_dot_raises  sP    %%f&;&;.#''(*
 	..0ABr   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )N""example" example"@example.comz""example" example"example exampler  @example.comrt  rY  s     r   /test_get_local_part_quoted_strings_in_atom_listz:TestParser.test_get_local_part_quoted_strings_in_atom_list  sP    %%f&;&;-!''(*
 	..0ABr   c                     | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       y )Nz#"\\"example\\" example"@example.comz"\\"example\\" example"z\example\\ exampler  r  rt  rY  s     r   5test_get_local_part_valid_and_invalid_qp_in_atom_listz@TestParser.test_get_local_part_valid_and_invalid_qp_in_atom_list  sP    %%f&;&;2&!''(*
 	..0EFr   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nu   exámple@example.comu   exámpler  )r.   r   rW  r   NonASCIILocalPartDefectr   rX  rY  s     r   "test_get_local_part_unicode_defectz-TestParser.test_get_local_part_unicode_defect  sL     %%f&;&;"++,
 	..
;r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y r
  )r.   r   	get_dtextr   r   r   dtexts     r   test_get_dtext_onlyzTestParser.test_get_dtext_only  r$  r   c                     | j                  t        j                  | j                  | j                  | j                  g d      }y r0   )r.   r   r  rfc_dtext_charsr  s     r   test_get_dtext_all_dtextz#TestParser.test_get_dtext_all_dtext  r(  r   c                 L    | j                  t        j                  dddg d       y r*  r.   r   r  r=   s    r   #test_get_dtext_two_words_gets_firstz.TestParser.test_get_dtext_two_words_gets_first  r.  r   c                 L    | j                  t        j                  dddg d       y r0  r  r=   s    r   &test_get_dtext_following_wsp_preservedz1TestParser.test_get_dtext_following_wsp_preserved  r2  r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d   j                  d   d       y )Nzfoo bar]r  ]r   r  )r.   r   r  r   ry   r   r'   r  r  s     r   test_get_dtext_non_printablesz(TestParser.test_get_dtext_non_printables  r8  r   c                 j    | j                  t        j                  dddt        j                  gd      }y )Nzfoo\]\[\\bar\b\e\l\lzfoo][\barbellr   )r.   r   r  r   rD  r   s     r   test_get_dtext_with_qpz!TestParser.test_get_dtext_with_qp  s2      !1!1!8!1!1"("="=!>!#%r   c                 L    | j                  t        j                  dddg d       y )Nzfoo]r9   r  r  r=   s    r   'test_get_dtext_up_to_close_bracket_onlyz2TestParser.test_get_dtext_up_to_close_bracket_only  #    ))ub#	7r   c                 L    | j                  t        j                  dddg d       y )Nzfoo  ]r9   z  ]r  r=   s    r   1test_get_dtext_wsp_before_close_bracket_preservedz<TestParser.test_get_dtext_wsp_before_close_bracket_preserved  #    )) %E	;r   c                 L    | j                  t        j                  dddg d       y )Nzfoo]barr9   z]barr  r=   s    r   %test_get_dtext_close_bracket_mid_wordz0TestParser.test_get_dtext_close_bracket_mid_word  r.  r   c                 L    | j                  t        j                  dddg d       y )Nzfoo[r9   [r  r=   s    r   &test_get_dtext_up_to_open_bracket_onlyz1TestParser.test_get_dtext_up_to_open_bracket_only  r  r   c                 L    | j                  t        j                  dddg d       y )Nzfoo  [r9   z  [r  r=   s    r   0test_get_dtext_wsp_before_open_bracket_preservedz;TestParser.test_get_dtext_wsp_before_open_bracket_preserved  r  r   c                 L    | j                  t        j                  dddg d       y )Nzfoo[barr9   z[barr  r=   s    r   $test_get_dtext_open_bracket_mid_wordz/TestParser.test_get_dtext_open_bracket_mid_word  r.  r   c                     | j                  t        j                  dddg d      x}}| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )N[127.0.0.1]r   zdomain-literal	127.0.0.1)r.   r   get_domain_literalr   r   domainipr   domain_literals     r   test_get_domain_literal_onlyz'TestParser.test_get_domain_literal_only  su    *.*:*:6;T;T - - - " "+$ 	$ 	224DE..>**K8r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz[  127.0.0.1	 ]z[ 127.0.0.1 ]r   r  r  r.   r   r  r   r  r  r  s     r   (test_get_domain_literal_with_internal_wsz3TestParser.test_get_domain_literal_with_internal_ws  sW    ))&*C*C 2 2 / " "$ 	..>**K8r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nz(foo)[  127.0.0.1] (bar)z [ 127.0.0.1] r   r  r  r  r  s     r   -test_get_domain_literal_with_surrounding_cfwsz8TestParser.test_get_domain_literal_with_surrounding_cfws  sW    ))&*C*C : : 0 " "$ 	..>**K8r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wNr  rS   r   rT   r   r  r=   s    r   ,test_get_domain_literal_no_start_char_raisesz7TestParser.test_get_domain_literal_no_start_char_raises'  s9    v667 	0%%h/	0 	0 	0rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) @r  r=   s    r   ;test_get_domain_literal_no_start_char_before_special_raiseszFTestParser.test_get_domain_literal_no_start_char_before_special_raises+  s9    v667 	1%%i0	1 	1 	1rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) [abc[@r  r=   s    r   <test_get_domain_literal_bad_dtext_char_before_special_raiseszGTestParser.test_get_domain_literal_bad_dtext_char_before_special_raises/  s9    v667 	6%%n5	6 	6 	6rW   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nexample.comr   r  r.   r   
get_domainr   r   r  r   r  s     r   #test_get_domain_regular_domain_onlyz.TestParser.test_get_domain_regular_domain_only5  U    !!&"3"3"/"/"/"$"$& 	**H56r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nr  r   r  r  r  s     r   #test_get_domain_domain_literal_onlyz.TestParser.test_get_domain_domain_literal_only?  r  r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz(foo) example.com(bar)	 example.com r   r  r.   r   r  r   r  r  s     r   test_get_domain_with_cfwsz$TestParser.test_get_domain_with_cfwsI  s?    !!&"3"3"<"<"1"$"$& 	6r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )N(foo)[127.0.0.1]	(bar) [127.0.0.1] r   r  r  r  s     r   (test_get_domain_domain_literal_with_cfwsz3TestParser.test_get_domain_domain_literal_with_cfwsR  s?    !!&"3"3";";"1"$"$& 	6r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz(foo)example.com	(bar), nextz(foo)example.com	(bar)r  , nextr  r  r  s     r   0test_get_domain_domain_with_cfws_ends_at_specialz;TestParser.test_get_domain_domain_with_cfws_ends_at_special[  ?    !!&"3"3"A";"1"$"*, 	6r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz(foo)[127.0.0.1]	(bar), nextr  r  r  r  r  r  s     r   8test_get_domain_domain_literal_with_cfws_ends_at_specialzCTestParser.test_get_domain_domain_literal_with_cfws_ends_at_speciald  r  r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nz(foo) example . (bird)com(bar)	z example . com r   r  )r.   r   r  r   rD  r   r  r  s     r   test_get_domain_obsoletez#TestParser.test_get_domain_obsoletem  sH    !!&"3"3"D"D"3#)#>#>"?"$& 	6r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr0   rS   r   rT   r   r  r=   s    r   test_get_domain_empty_raisesz'TestParser.test_get_domain_empty_raisesv  s9    v667 	"b!	" 	" 	"rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz  (foo)	r  r=   s    r   "test_get_domain_no_non_cfws_raisesz-TestParser.test_get_domain_no_non_cfws_raisesz  9    v667 	+k*	+ 	+ 	+rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz  (foo)	, brokenr  r=   s    r   test_get_domain_no_atom_raisesz)TestParser.test_get_domain_no_atom_raises~  s:    v667 	312	3 	3 	3rW   c                 ,   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                  d       y )Ndinsdale@example.comr   z	addr-specrS  r  )r.   r   get_addr_specr   r   rX  r  	addr_specr   r  s     r   test_get_addr_spec_normalz$TestParser.test_get_addr_spec_normal  s    $$V%9%9$:$:$:$&$&(	 	--{;--z:))=9,,.DEr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )Nzdinsdale@[127.0.0.1]r   rS  r  r.   r   r  r   rX  r  r  r  s     r   &test_get_addr_spec_with_doamin_literalz1TestParser.test_get_addr_spec_with_doamin_literal  sn    $$V%9%9$:$:$:$&$&(	 	--z:))=9,,.DEr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )Nz-(foo) dinsdale(bar)@ (bird) example.com (bog)z dinsdale@example.com r   rS  r  r  r  r  s     r   test_get_addr_spec_with_cfwsz'TestParser.test_get_addr_spec_with_cfws  sn    $$V%9%9??(	 	--z:))=9,,.DEr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )Nz0(foo) "roy a bug"(bar)@ (bird) example.com (bog) "roy a bug"@example.com r   	roy a bugr  "roy a bug"@example.comr  r  s     r   /test_get_addr_spec_with_qouoted_string_and_cfwsz:TestParser.test_get_addr_spec_with_qouoted_string_and_cfws  sn    $$V%9%9BB+	 	--{;))=9,,.GHr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )Nz7(foo) "roy a bug"(bar)@ (bird) example.com (bog) , nextz1(foo) "roy a bug"(bar)@ (bird) example.com (bog) r  r  r  r  r  r  r  s     r   "test_get_addr_spec_ends_at_specialz-TestParser.test_get_addr_spec_ends_at_special  sn    $$V%9%9IC+	 	--{;))=9,,.GHr   c                    | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       y Nr  example example@example.comr  r   r  r  "example example"@example.com)	r.   r   r  r   re   r   rX  r  r  r  s     r   .test_get_addr_spec_quoted_strings_in_atom_listz9TestParser.test_get_addr_spec_quoted_strings_in_atom_list  s}    $$V%9%9--)''(*	 	--/@A))=9,,.MNr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       y )Nzstar.a.star@example.comr   zstar.a.starr  r  r  s     r   test_get_addr_spec_dot_atomz&TestParser.test_get_addr_spec_dot_atom  sn    $$V%9%9%%%	 	--}=))=9,,.GHr   c                    | j                  t        j                        5  t        j                  d       d d d        | j                  t        j                        5  t        j                  d       d d d        | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   y xY w)Nzstar@a.star@example.comzstar@a@example.comzstar@172.17.0.1@example.com)rS   r   rT   r   r  r=   s    r   #test_get_addr_spec_multiple_domainsz.TestParser.test_get_addr_spec_multiple_domains  s    v667 	<  !:;	< v667 	7  !56	7 v667 	@  !>?	@ 	@	< 	<	7 	7	@ 	@r  c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  ddg       y )Nz@example.com, @two.example.com:r   	obs-router  two.example.com)r.   r   get_obs_router   r   domainsr   	obs_routes     r   test_get_obs_route_simplez$TestParser.test_get_obs_route_simple  s]    $$V%9%9---	 	--{;**]<M,NOr   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  ddg       y )Nz?(foo),, (blue)@example.com (bar),@two.(foo) example.com (bird):z% ,, @example.com ,@two. example.com :r   r	  r  r
  )r.   r   r  r   rD  r   r   r  r  s     r   test_get_obs_route_complexz%TestParser.test_get_obs_route_complex  sf    $$V%9%9MM3(()	 	--{;**]<M,NOr   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) @example.com,rS   r   rT   r   r  r=   s    r   -test_get_obs_route_no_route_before_end_raisesz8TestParser.test_get_obs_route_no_route_before_end_raises  s:    v667 	8  !67	8 	8 	8rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) @example.com, (foo) r  r=   s    r   .test_get_obs_route_no_route_before_end_raises2z9TestParser.test_get_obs_route_no_route_before_end_raises2  s:    v667 	?  !=>	? 	? 	?rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) [abc],r  r=   s    r   1test_get_obs_route_no_route_before_special_raisesz<TestParser.test_get_obs_route_no_route_before_special_raises  s9    v667 	1  0	1 	1 	1rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) @example.com [abc],r  r=   s    r   2test_get_obs_route_no_route_before_special_raises2z=TestParser.test_get_obs_route_no_route_before_special_raises2  s:    v667 	>  !<=	> 	> 	>rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)N@r  r=   s    r   ,test_get_obs_route_no_domain_after_at_raisesz7TestParser.test_get_obs_route_no_domain_after_at_raises  s9    v667 	&  %	& 	& 	&rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz@example.com, @r  r=   s    r   -test_get_obs_route_no_domain_after_at_raises2z8TestParser.test_get_obs_route_no_domain_after_at_raises2  s:    v667 	4  !23	4 	4 	4rW   c                 b   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )N<dinsdale@example.com>r   
angle-addrrS  r  r  
r.   r   get_angle_addrr   r   rX  r  assertIsNonerouter  r   
angle_addrs     r   test_get_angle_addr_simplez%TestParser.test_get_angle_addr_simple  s    %%f&;&;$$$
 	..=..
;**M:***+--/EFr   c                 |   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                         | j                  |j                         | j                  |j                         | j                  |j                  d       y )N<>r   r"  )r.   r   r$  r   re   r   r   r%  rX  r  r&  r  r'  s     r   test_get_angle_addr_emptyz$TestParser.test_get_angle_addr_empty  s    %%f&;&;''(
 	..=*//0*++,***+--t4r   c                 b   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz<""@example.com>r   r"  r  z""@example.comr#  r'  s     r   "test_get_angle_addr_qs_only_quotesz-TestParser.test_get_angle_addr_qs_only_quotes'  s    %%f&;&;
 	..=..3**M:***+--/?@r   c                 b   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz" (foo) <dinsdale@example.com>(bar)z <dinsdale@example.com> r   r"  rS  r  r  r#  r'  s     r   test_get_angle_addr_with_cfwsz(TestParser.test_get_angle_addr_with_cfws4  s    %%f&;&;00&
 	..=..
;**M:***+--/EFr   c                 *   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                         | j                  |j                  d       y )Nz<"Fred Perfect"@[127.0.0.1]>r   zFred Perfectr  z"Fred Perfect"@[127.0.0.1]	r.   r   r$  r   rX  r  r%  r&  r  r'  s     r   )test_get_angle_addr_qs_and_domain_literalz4TestParser.test_get_angle_addr_qs_and_domain_literalA  s    %%f&;&;***
 	..?**M:***+--/KLr   c                 *   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                         | j                  |j                  d       y )Nz!<(foo) dinsdale@example.com(bar)>z< dinsdale@example.com >r   rS  r  r  r2  r'  s     r   !test_get_angle_addr_internal_cfwsz,TestParser.test_get_angle_addr_internal_cfwsM  s    %%f&;&;//&
 	..
;**M:***+--/EFr   c                 N   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  ddg       | j                  |j                  d       y )NzI(foo)<@example.com, (bird) @two.example.com: dinsdale@example.com> (bar) z8 <@example.com, @two.example.com: dinsdale@example.com> r   rS  r  r
  r  )
r.   r   r$  r   rD  r   rX  r  r&  r  r'  s     r   test_get_angle_addr_obs_routez(TestParser.test_get_angle_addr_obs_routeY  s    %%f&;&;WWF(()
 	..
;**M:))M;L+MN--/EFr   c                 H   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz<dinsdale@example.comr!  r   rS  r  r  r.   r   r$  r   re   r   rX  r  r%  r&  r  r'  s     r   )test_get_angle_addr_missing_closing_anglez4TestParser.test_get_angle_addr_missing_closing_anglee  s    %%f&;&;#$$''(
 	..
;**M:***+--/EFr   c                 H   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz<dinsdale@example.com (foo)z<dinsdale@example.com (foo)>z<dinsdale@example.com >r   rS  r  r  r9  r'  s     r   3test_get_angle_addr_missing_closing_angle_with_cfwsz>TestParser.test_get_angle_addr_missing_closing_angle_with_cfwsq  s    %%f&;&;)*%''(
 	..
;**M:***+--/EFr   c                 *   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                         | j                  |j                  d       y )Nz"<dinsdale@example.com> (foo), nextz<dinsdale@example.com> (foo)z<dinsdale@example.com> r  rS  r  r  r2  r'  s     r   #test_get_angle_addr_ends_at_specialz.TestParser.test_get_angle_addr_ends_at_special}  s    %%f&;&;0*%
 	..
;**M:***+--/EFr   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr0   rS   r   rT   r   r$  r=   s    r   test_get_angle_addr_empty_raisez*TestParser.test_get_angle_addr_empty_raise  ry  rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)N<r@  r=   s    r   )test_get_angle_addr_left_angle_only_raisez4TestParser.test_get_angle_addr_left_angle_only_raise  s9    v667 	'!!#&	' 	' 	'rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr  r@  r=   s    r   "test_get_angle_addr_no_angle_raisez-TestParser.test_get_angle_addr_no_angle_raise  s9    v667 	,!!(+	, 	, 	,rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) , nextr@  r=   s    r   2test_get_angle_addr_no_angle_before_special_raisesz=TestParser.test_get_angle_addr_no_angle_before_special_raises  9    v667 	2!!.1	2 	2 	2rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nr   r@  r=   s    r   #test_get_angle_addr_no_angle_raisesz.TestParser.test_get_angle_addr_no_angle_raises  s9    v667 	)!!%(	) 	) 	)rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz(foo) <, barr@  r=   s    r   .test_get_angle_addr_special_after_angle_raisesz9TestParser.test_get_angle_addr_special_after_angle_raises  rI  rW   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )NzFred A Johnsonr   display-namer.   r   get_display_namer   r   display_namer   rR  s     r   test_get_display_name_simplez'TestParser.test_get_display_name_simple  sX    ''(?(? 	00.A224DEr   c                     | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       y )Nr/  r0  z"Fred A. Johnson is his name"r2  rO  r1  rP  rS  s     r   test_get_display_name_complex1z)TestParser.test_get_display_name_complex1  sX    ''(?(?0++ 	00.A224QRr   c                    | j                  t        j                  dddg d      }| j                  |d   d   j                  dg       | j                  |d   d   j                  dg       | j                  |j
                  d	       y )
Nr8  r9  z "bird hand   is messy" r:  r   r;  r   r<  zbird hand   is messy)r.   r   rQ  r   r#   rR  rS  s     r   test_get_display_name_complex2z)TestParser.test_get_display_name_complex2  s    ''(?(?>:& 	a+44se<a+44~6FG224JKr   c                    | j                  t        j                  dddt        j                  gdz  d      }| j                  t        |      d       | j                  |d   j                  dg       | j                  |j                  d       y )Nr?  z"Fred A. .O Johnson"r  r   rA  rB  r@  	r.   r   rQ  r   rD  r   r  r#   rR  rS  s     r   test_get_display_name_obsoletez)TestParser.test_get_display_name_obsolete  s    ''(?(?&&"(()!+ 	\*A.a11G9=224HIr   c           	      B   | j                  t        j                  dddt        j                  gt        j
                  gdz  z   d      }| j                  t        |      d       | j                  |d   j                  dg       | j                  |j                  d       y )	NrG  z ".name"r   r   r  r   rH  z.name)
r.   r   rQ  r   re   rD  r   r  r#   rR  rS  s     r   1test_get_display_name_pharse_must_start_with_wordz<TestParser.test_get_display_name_pharse_must_start_with_word  s    ''(?(?!!''(F,G,G+H+JJ 	\*A.a11N3CD22G<r   c                    | j                  t        j                  dddt        j                  gdz  d      }| j                  t        |      d       | j                  |d   j                  dg       | j                  |j                  d	       y )
NrK  rL  z"simple phrase." r   rM  r  r  rN  zsimple phrase.rZ  rS  s     r   *test_get_display_name_ending_with_obsoletez5TestParser.test_get_display_name_ending_with_obsolete  s    ''(?(?73(()!+ 	\*A.a114K3LM224DEr   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nz:Foo r   )r.   r   rQ  r   re   r   r   rS  s     r   /test_get_display_name_for_invalid_address_fieldz:TestParser.test_get_display_name_for_invalid_address_field  sJ     ''##Rf8897D 	++R0r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j                         | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nr!  r   	name-addrrS  r  r  )r.   r   get_name_addrr   r   r%  rR  rX  r  r&  r  r   	name_addrs     r   "test_get_name_addr_angle_addr_onlyz-TestParser.test_get_name_addr_angle_addr_only  s    $$V%9%9$$$	 	--{;)001--z:))=9)//*,,.DEr   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )NzDinsdale <dinsdale@example.com>r   rc  DinsdalerS  r  r  )r.   r   rd  r   r   rR  rX  r  r%  r&  r  re  s     r   test_get_name_addr_atom_namez'TestParser.test_get_name_addr_atom_name  s    $$V%9%9---	 	--{;//<--z:))=9)//*,,.DEr   c                 b   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz2(foo) Dinsdale (bar) <dinsdale@example.com> (bird)z! Dinsdale <dinsdale@example.com> r   ri  rS  r  r  
r.   r   rd  r   rR  rX  r  r%  r&  r  re  s     r   &test_get_name_addr_atom_name_with_cfwsz1TestParser.test_get_name_addr_atom_name_with_cfws	  s    $$V%9%9@@/	 	//<--z:))=9)//*,,.DEr   c                    | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )	Nz4(foo) Roy.A.Bear (bar) <dinsdale@example.com> (bird)z% "Roy.A.Bear" <dinsdale@example.com> r   r   
Roy.A.BearrS  r  r  r.   r   rd  r   rD  r   rR  rX  r  r%  r&  r  re  s     r   *test_get_name_addr_name_with_cfws_and_dotsz5TestParser.test_get_name_addr_name_with_cfws_and_dots  s    $$V%9%9BB3(()!+	 	//>--z:))=9)//*,,.DEr   c                 b   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )N#"Roy.A.Bear" <dinsdale@example.com>r   ro  rS  r  r  rl  re  s     r   test_get_name_addr_qs_namez%TestParser.test_get_name_addr_qs_name#  s    $$V%9%9111	 	//>--z:))=9)//*,,.DEr   c                    | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )NzJohn X.<jxd@example.com>z"John X."<jxd@example.com>r   zJohn X.jxdr  jxd@example.comrp  re  s     r   0test_get_name_addr_ending_with_dot_without_spacez;TestParser.test_get_name_addr_ending_with_dot_without_space0  s    $$V%9%9&&((()	 	//;--u5))=9)//*,,.?@r   c                    | j                  t        j                  dddt        j                  t        j
                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz. Doe <jxd@example.com>z". Doe" <jxd@example.com>r   z. Doerv  r  rw  )r.   r   rd  r   re   rD  r   rR  rX  r  r%  r&  r  re  s     r   $test_get_name_addr_starting_with_dotz/TestParser.test_get_name_addr_starting_with_dot=  s    $$V%9%9%%''')D)DE	 	//9--u5))=9)//*,,.?@r   c                    | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  dg       | j                  |j                  d       y )Nz5"Roy.A.Bear" <@two.example.com: dinsdale@example.com>r   ro  rS  r  r
  r  )r.   r   rd  r   rD  r   rR  rX  r  r&  r  re  s     r   test_get_name_addr_with_routez(TestParser.test_get_name_addr_with_routeJ  s    $$V%9%9CCC(()	 	//>--z:))=9+<*=>,,.DEr   c                 b   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nz)"Roy.A.Bear" <dinsdale@example.com>, nextrs  r  ro  rS  r  r  rl  re  s     r   "test_get_name_addr_ends_at_specialz-TestParser.test_get_name_addr_ends_at_specialW  s    $$V%9%9711	 	//>--z:))=9)//*,,.DEr   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr0   rS   r   rT   r   rd  r=   s    r   test_get_name_addr_empty_raisesz*TestParser.test_get_name_addr_empty_raisesd  s9    v667 	%  $	% 	% 	%rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr  r  r=   s    r   $test_get_name_addr_no_content_raisesz/TestParser.test_get_name_addr_no_content_raisesh  9    v667 	,  +	, 	, 	,rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz (foo) ,r  r=   s    r   3test_get_name_addr_no_content_before_special_raisesz>TestParser.test_get_name_addr_no_content_before_special_raisesl  s9    v667 	-  ,	- 	- 	-rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nr+  r  r=   s    r   5test_get_name_addr_no_angle_after_display_name_raisesz@TestParser.test_get_name_addr_no_angle_after_display_name_raisesp  r  rW   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j                         | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nr  r   mailboxrS  r  r.   r   get_mailboxr   r   r%  rR  rX  r  r&  r  r   r  s     r   test_get_mailbox_addr_spec_onlyz*TestParser.test_get_mailbox_addr_spec_onlyv  s    ""6#5#5""" 	++Y7'../++Z87'--(**,BCr   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j                         | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )Nr!  r   r  rS  r  r  r  r  s     r    test_get_mailbox_angle_addr_onlyz+TestParser.test_get_mailbox_angle_addr_only  s    ""6#5#5$$$ 	++Y7'../++Z87'--(**,BCr   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )N$"Roy A. Bear" <dinsdale@example.com>r   r  Roy A. BearrS  r  r  r.   r   r  r   r   rR  rX  r  r%  r&  r  r  s     r   test_get_mailbox_name_addrz%TestParser.test_get_mailbox_name_addr  s    ""6#5#5222 	++Y7--}=++Z87'--(**,BCr   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       y )	Nz*"Roy A. Bear" <dinsdale@example.com>, restr  z, restr  r  rS  r  r  r  r  s     r    test_get_mailbox_ends_at_specialz+TestParser.test_get_mailbox_ends_at_special  s    ""6#5#5822 	++Y7--}=++Z87'--(**,BCr   c                    | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       y r   )	r.   r   r  r   re   r   rX  r  r  r  s     r   ,test_get_mailbox_quoted_strings_in_atom_listz7TestParser.test_get_mailbox_quoted_strings_in_atom_list  s{    ""6#5#5--)''(* 	++->?7**,KLr   c                 L   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       |j                  d   }| j                  |j                         | j                  |j                  d       | j                  |j                  d       | j                  |j                         | j                  |j                  d       | j                  |j                  |j                         y )Nr  r   mailbox-listr:   r   rS  r  )r.   r   get_mailbox_listr   r   r  	mailboxesr%  rR  rX  r  r&  r  all_mailboxes)r   mailbox_listr  s      r   !test_get_mailbox_list_single_addrz,TestParser.test_get_mailbox_list_single_addr  s    ''(?(?""" 	00.A\334a8((+'../++Z87'--(**,BC//%33	5r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  |j                         y )	Nz/dinsdale@example.com, dinsdale@test.example.comr   r  r   r   r  r:   dinsdale@test.example.com)	r.   r   r  r   r   r  r  r  r  r   r  s     r   %test_get_mailbox_list_two_simple_addrz0TestParser.test_get_mailbox_list_two_simple_addr  s    ''(?(?=== 	00.A\334a8//2<<.	0//2<<3	5//%33	5r   c                 *   | j                  t        j                  dddg d      }| j                  t	        |j
                        d       | j                  |j
                  d   j                  d       | j                  |j
                  d   j                  d       | j                  |j
                  d   j                  d       | j                  |j
                  d   j                  d	       | j                  |j
                  |j                         y )
NzS"Roy A. Bear" <dinsdale@example.com>, "Fred Flintstone" <dinsdale@test.example.com>r   r   r   r  r  r:   r  Fred Flintstone)	r.   r   r  r   r  r  r  rR  r  r  s     r   #test_get_mailbox_list_two_name_addrz.TestParser.test_get_mailbox_list_two_name_addr  s    ''(?(?AAA 	\334a8//2<<.	0//2??%	'//2<<3	5//2??)	+//%33	5r   c                 H   | j                  t        j                  dddt        j                  gd      }| j                  t        |j                        d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d	       | j                  |j                  d   j                  d
       | j                  |j                  |j                         y )Nzd(foo) "Roy A. Bear" <dinsdale@example.com>(bar), "Fred Flintstone" <dinsdale@test.(bird)example.com>zV "Roy A. Bear" <dinsdale@example.com> , "Fred Flintstone" <dinsdale@test. example.com>r   r   r   r  r  r:   r  r  )r.   r   r  r   rD  r   r  r  r  rR  r  r  s     r   !test_get_mailbox_list_two_complexz,TestParser.test_get_mailbox_list_two_complex  s   ''(?(?GGB(() 	\334a8//2<<.	0//2??%	'//2<<3	5//2??)	+//%33	5r   c           
         | j                  t        j                  dddt        j                  t        j                  t        j
                  t        j
                  gd      }| j                  t        |j                        d       | j                  t        |j                        d       | j                  |j                  d   j                  d       | j                  |j                  d   j                         | j                  |j                  d   j                  d       | j                  |j                  d   j                         | j                  |j                  d   j                  d	       | j!                  |j                  d   |j                  d          | j                  |j                  d   j                  d
       | j                  |j                  d   j                  d       y )NzY"Roy A. Bear"[] dinsdale@example.com, "Fred Flintstone" <dinsdale@test.(bird)example.com>zT"Roy A. Bear"[] dinsdale@example.com, "Fred Flintstone" <dinsdale@test. example.com>r   r:   r   r   invalid-mailboxr  z"Roy A. Bear"r  r  )r.   r   r  r   re   rD  r   r  r  r  r   r%  rR  rX  r  r  assertIsr  s     r   .test_get_mailbox_list_unparseable_mailbox_nullz9TestParser.test_get_mailbox_list_unparseable_mailbox_null	  s   ''(?(?GGB''''((((*  	\334a8\778!<33A6AA)	+,44Q7DDE33A6AA%	',44Q7>>?33A6@@'	)l003$..q1	3//2<<3	5//2??)	+r   c                    | j                  t        j                  dddt        j                  gd      }| j                  t        |j                        d       | j                  t        |j                        d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   |j                  d          | j                  |j                  d   j                  d	       | j                  |j                  d   j                  d
       y )NzU"Roy A. Bear" <dinsdale@example.com>@@, "Fred Flintstone" <dinsdale@test.example.com>r   r:   r   r   r  r  r  r  r  )r.   r   r  r   re   r   r  r  r  r  rR  r   r  r  s     r   .test_get_mailbox_list_junk_after_valid_addressz9TestParser.test_get_mailbox_list_junk_after_valid_address'  sN   ''(?(?AAA''( 	\334a8\778!<33A6@@.	033A6CC%	'33A6AA)	+l003$..q1	3//2<<3	5//2??)	+r   c                 N   | j                  t        j                  dddt        j                  gdz  d      }| j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d	       | j                  |j                  d   j                  d
       y )Nz\"Roy A. Bear" <dinsdale@example.com>, (bird),, "Fred Flintstone" <dinsdale@test.example.com>zV"Roy A. Bear" <dinsdale@example.com>, ,, "Fred Flintstone" <dinsdale@test.example.com>r   r   r   r  r  r:   r  r  )r.   r   r  r   rD  r   r  r  r  r  rR  r  s     r   (test_get_mailbox_list_empty_list_elementz3TestParser.test_get_mailbox_list_empty_list_element@  s   ''(?(?AAA(()!+ 	\334a833%//	133A6@@.	033A6CC%	'//2<<3	5//2??)	+r   c                    | j                  t        j                  dddt        j                  gdz  d      }| j                  t        |j                        d       | j                  |j                  |j                         y )Nz(foo),, (bar)z ,, r  r   r   )	r.   r   r  r   rD  r   r  r  r  r  s     r   )test_get_mailbox_list_only_empty_elementsz4TestParser.test_get_mailbox_list_only_empty_elementsV  ss    ''(?(?(()!+ 	\334a833%//	1r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         y )Nz	(hidden);z(hidden)r@   ;
group-listr   )r.   r   get_group_listr   r   r  r  r  r   
group_lists     r   test_get_group_list_cfws_onlyz(TestParser.test_get_group_list_cfws_onlyc  s{    %%f&;&;
 	..=Z112A6--#11	3r   c                 l   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       y )Nz;dinsdale@example.org, "Fred A. Bear" <dinsdale@example.org>r   r  r   r:   Fred A. Bear)	r.   r   r  r   r   r  r  r  rR  r  s     r    test_get_group_list_mailbox_listz+TestParser.test_get_group_list_mailbox_listo  s    %%f&;&;III
 	..=Z112A6--#11	3--a0=='	)r   c                 8   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         y )Nz, (foo),,(bar)z, ,, r   r  r   )
r.   r   r  r   rD  r   r   r  r  r  r  s     r   "test_get_group_list_obs_group_listz-TestParser.test_get_group_list_obs_group_list}  s    %%f&;&;(()
 	..=Z112A6--#11	3r   c                 8   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         y )Nz(bar)r@   r   r  r   )
r.   r   r  r   re   r   r   r  r  r  r  s     r   (test_get_group_list_comment_only_invalidz3TestParser.test_get_group_list_comment_only_invalid  s    %%f&;&;''(
 	..=Z112A6--#11	3r   c                 R   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  t        |j                        d       | j                  |j                  |j                         y )NMonty Python:;r   groupMonty Pythonr   	r.   r   	get_groupr   r   rR  r  r  r  r   r  s     r   test_get_group_emptyzTestParser.test_get_group_empty  s      !1!1 	))73++^<U__-q1,,	.r   c                    | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  t        |j                        d       | j                  |j                  d   j                  d       y )Nzfoo: <>;r   r9   r   r:   r+  )r.   r   r  r   re   r   rR  r  r  r  r   r  s     r   test_get_group_null_addr_specz(TestParser.test_get_group_null_addr_spec  s      !1!1''( 	++U3U__-q1U00115,,Q/55t<r   c                 R   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  t        |j                        d       | j                  |j                  |j                         y )NzMonty Python: (hidden);Monty Python: ;r   r  r  r   r  r  s     r   test_get_group_cfws_onlyz#TestParser.test_get_group_cfws_only  s      !1!1%% 	))73++^<U__-q1,,	.r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       y )Nz4Monty Python: "Fred A. Bear" <dinsdale@example.com>;r   r  r  r:   r   r  )
r.   r   r  r   r   rR  r  r  r  r  r  s     r   test_get_group_single_mailboxz(TestParser.test_get_group_single_mailbox  s      !1!1BBB 	))73++^<U__-q1,,	.+55/	1r   c                 H   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  |j
                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j
                  d       | j                  |j                  d	   j
                  d
       | j                  |j                  d   j                  d       y )NzhMonty Python: "Fred A. Bear" <dinsdale@example.com>,(foo) Roger <ping@exampele.com>, x@test.example.com;zcMonty Python: "Fred A. Bear" <dinsdale@example.com>, Roger <ping@exampele.com>, x@test.example.com;r   r  r  r  r   r  r:   Rogerr   r   )
r.   r   r  r   r   rR  r  r  r  rX  r  s     r   test_get_group_mixed_listz$TestParser.test_get_group_mixed_list  s      !1!1GGB 	))73++^<U__-q1,,	.+88'	)+88 	"+66<r   c                    | j                  t        j                  dddt        j                  t        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  t        |j                        d       | j                  t        |j                        d       | j                  |j                  d   j                  d	       | j                  |j                  d
   j                  d       | j                  |j                  d
   j                         y )NzfMonty Python: "Fred A. Bear" <dinsdale@example.com>,(foo) Roger ping@exampele.com, x@test.example.com;zaMonty Python: "Fred A. Bear" <dinsdale@example.com>, Roger ping@exampele.com, x@test.example.com;r   r  r  r   r  r   r  r:   r   )r.   r   r  r   re   r   r   rR  r  r  r  rX  r%  r  s     r   test_get_group_one_invalidz%TestParser.test_get_group_one_invalid  s     !1!1EE@'''')	 	))73++^<U__-q1U00115+88'	)+66<%--a0==>r   c                 
   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |j                  d   j                  d	       | j                  |j                  d
   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       y )NzSMonty Python:"Fred A. Bear" <dinsdale@example.com>,eric@where.test,John <jdoe@test>zTMonty Python:"Fred A. Bear" <dinsdale@example.com>,eric@where.test,John <jdoe@test>;r   r  r  r  r   r  r  r:   zeric@where.testr   Johnz	jdoe@test)r.   r   r  r   re   r   r   rR  r  r  r  r  r  s     r   $test_get_group_missing_final_semicolz/TestParser.test_get_group_missing_final_semicol  sF     !1!1011''( 	))73++^<U__-q1,,	.+55/	1+88'	)+55*	,+88	!+55$	&r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |d   j                  d       y )Nr  r   addressr:   r   r  r  	r.   r   get_addressr   r   r  r  r  r  r   r  s     r   test_get_address_simplez"TestParser.test_get_address_simple	  s    ""6#5#5""" 	++Y7W../3** ..	0**1-44&	(.."	$r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |d   j                  d       y )	Nz1(foo) "Fred A. Bear" <(bird)dinsdale@example.com>z' "Fred A. Bear" < dinsdale@example.com>r   r  r:   r   r  r  	r.   r   r  r   r   r  r  r  rR  r  s     r   test_get_address_complexz#TestParser.test_get_address_complex 	  s    ""6#5#5??5 	++Y7W../3** ..	0**1-::'	).."	$r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |d   j                  d       y )	Nz'=?utf-8?q?=C3=89ric?= <foo@example.com>u   Éric <foo@example.com>r   r  r:   r   r~   r  r  r  s     r   %test_get_address_rfc2047_display_namez0TestParser.test_get_address_rfc2047_display_name0	  s    ""6#5#55%% 	++Y7W../3** ..	0**1-:: 	".."	$r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |d   j                  d       | j                  |d   j                  d       y )Nr  r   r  r   r  r  r  r  s     r   test_get_address_empty_groupz'TestParser.test_get_address_empty_group@	  s    ""6#5#5 	++Y7W../3** ..	0.. 	"00'	)r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |d   j                  d       | j                  |d   j                  d       | j                  |j                  d   j                  d       y )	Nz+Monty Python: x@example.com, y@example.com;r   r  r   r   r  r  r   )
r.   r   r  r   r   r  r  r  rR  rX  r  s     r   test_get_address_groupz!TestParser.test_get_address_groupP	  s    ""6#5#5999 	++Y7W../3** ..	0.. 	"00'	)**1-88#>r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |d   j                  d       y )	Nz"foo bar"@example.comr   r  r:   r   r  r+  r  )
r.   r   r  r   r   r  r  r  r  rX  r  s     r   "test_get_address_quoted_local_partz-TestParser.test_get_address_quoted_local_parta	  s    ""6#5#5### 	++Y7W../3** ..	0**1-44&	(**1-88"	$..	:r   c                    | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |d   j                  d       y )	Nzdinsdale@example.com, nextr  r  r  r:   r   r  r  r  r  s     r    test_get_address_ends_at_specialz+TestParser.test_get_address_ends_at_specialr	  s    ""6#5#5("" 	++Y7W../3** ..	0**1-44&	(..	:r   c           	      R   | j                  t        j                  dddt        j                  t        j                  t        j                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  t        |j                        d       | j                  |j                  d   j                         | j                  |j                  d   j                  d       | j                  |d   j                  d       y )Nzping example.com, nextzping example.comr  r  r   r:   r  )r.   r   r  r   re   r   r   r  r  r  r%  r  rX  r  s     r   (test_get_address_invalid_mailbox_invalidz3TestParser.test_get_address_invalid_mailbox_invalid	  s    ""6#5#5$''''''  	++Y7W../3W223Q7'//299:..q1<<>PQ..0ABr   c                 f   | j                  t        j                  dddt        j                  gdz  d      }| j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       y )	Nr  r  r  r   r   r  r  r  )
r.   r   r  r   re   r   r  rX  r  r  r  s     r   ,test_get_address_quoted_strings_in_atom_listz7TestParser.test_get_address_quoted_strings_in_atom_list	  s    ""6#5#5--)''(* 	..q1<<>OP..q188-H..q1;;=\]r   c                 8   | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         y )Nz(Recipient list suppressed)r@   r   address-listr   )
r.   r   get_address_listr   rD  r   r   r  r  r  r   address_lists     r   test_get_address_list_CFWSz%TestParser.test_get_address_list_CFWS	  s    ''(?(?(E(E(+)/)D)D(E(*, 	00.A\334a8//1K1KLr   c           	         | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  D cg c]  }t        |       c}|j                  D cg c]  }t        |       c}       | j                  |j                  d   j                  d       | j                  |d   j                  d       | j                  |d   j                         y c c}w c c}w )Nr  r   r  r:   r   r  r  )r.   r   r  r   r   r  r  r  r   	addressesr  r%  rR  r   r  r   s      r   &test_get_address_list_mailboxes_simplez1TestParser.test_get_address_list_mailboxes_simple	  s   ''(?(?""" 	00.A\334a8//%33	5,*@*@AQ#a&A*6*@*@AQ#a&A	C//299=Ia33Y?,q/667	 BAs   %EE
c           	      z   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  D cg c]  }t        |       c}|j                  D cg c]  }t        |       c}       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       y c c}w c c}w )	Nz0foo@example.com, "Fred A. Bar" <bar@example.com>r   r  r   r   r9   r:   zFred A. Bar)r.   r   r  r   r   r  r  r  r   r  rX  rR  r  s      r   *test_get_address_list_mailboxes_two_simplez5TestParser.test_get_address_list_mailboxes_two_simple	  s   ''(?(?>>> 	00.A\334a8//%33	5,*@*@AQ#a&A*6*@*@AQ#a&A	C//2==uE//2??O BAs   %D3D8
c           	         | j                  t        j                  dddt        j                  t        j                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  D cg c]  }t        |       c}|j                  D cg c]  }t        |       c}       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d	       | j                  |j                  d
   j                  d       | j                  |j                  d   j                  d       y c c}w c c}w )Nzn"Roy A. Bear" <dinsdale@example.com>, (ping) Foo <x@example.com>,Nobody Is. Special <y@(bird)example.(bad)com>z_"Roy A. Bear" <dinsdale@example.com>, Foo <x@example.com>,"Nobody Is. Special" <y@example. com>r   r  r  r   r  r  r  r:   r   r   Nobody Is. Special)r.   r   r  r   rD  r   r   r  r  r  r   r  r  rX  rR  r  s      r   'test_get_address_list_mailboxes_complexz2TestParser.test_get_address_list_mailboxes_complex	  s   ''(?(?@@8 (('') 	00.A\334a8//%33	5,*@*@AQ#a&A*6*@*@AQ#a&A	C//299=I//2==yI//2==yI//2==sC//2??-	/ BAs   G%G
c                    | j                  t        j                  dddt        j                  t        j                  t        j                  t        j
                  t        j                  t        j
                  gd      }| j                  |j                  d       | j                  t        |j                        d       | j                  t        |j                        d       | j                  |j                  D cg c]  }t        |       c}|j                  D cg c]  }t        |       c}       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d	       | j                  |j                  d   j                  d
       | j                  |j                  d   j                  d
       | j                  t        |j                  d   j                        d       | j                  t        |j                  d   j                        d       | j                  t        |j                  d   j                        d       | j                  |j                  d   j                  d   j                  d       | j                  |j                  d   j                  d   j                  d       y c c}w c c}w )Nzl"Roy A. Bear" <dinsdale@example.com>, (ping) Foo x@example.com[],Nobody Is. Special <(bird)example.(bad)com>z^"Roy A. Bear" <dinsdale@example.com>, Foo x@example.com[],"Nobody Is. Special" < example. com>r   r  r:   r  r   r  r  r  zFoo xr   r  )r.   r   r  r   re   rD  r   r   r  r  r  r   r  r  rX  rR  r  s      r   1test_get_address_list_mailboxes_invalid_addressesz<TestParser.test_get_address_list_mailboxes_invalid_addresses	  sV   ''(?(?>>7 (((((())(())+ !" 	00.A\334a8\778!<,*D*DEQ#a&E*6*@*@AQ#a&A	C//299=I//2==yI//2==yI//2==yI\33A6@@A1E\33A6@@A1E\33A6@@A1E""1%33A6AA7	L""1%33A6CC$	& FAs   >K  K%
c                 l   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  t        |j                        d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  t        |j                  d   j                        d       y )Nr  r   r  r   r:   r  r  )
r.   r   r  r   r   r  r  r  r  rR  r  s     r   !test_get_address_list_group_emptyz,TestParser.test_get_address_list_group_empty
  s    ''(?(? 	00.A\334a8//%33	5\334a8//2==yI//2??P\33A6@@A1Er   c                 *   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d   j                  d       y )Nz#Monty Python: dinsdale@example.com;r   r  r:   r   r  r  )r.   r   r  r   r   r  r  r  r  r  rR  r  s     r   "test_get_address_list_group_simplez-TestParser.test_get_address_list_group_simple
  s    ''(?(?111 	00.A\334a8//%33	5//299=I//2??'	)//2<<Q?FF&	(r   c                 4   | j                  t        j                  dddg d      }| j                  |j                  d       | j                  t        |j                        d       | j                  |j                  |j                         | j                  t        |j                        d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d   j                  d	       | j                  |j                  d   j                  d
   j                  d       | j                  |j                  d
   j                  d   j                  d       | j                  |j                  d   j                  d   j                  d       | j                  t        |j                  d
         t        |j                  d                y )NziMonty Python: dinsdale@example.com, "Fred" <flint@example.com>;, Abe <x@example.com>, Bee <y@example.com>r   r  r  r  r   rS  r  r  r:   flintr   r   y)r.   r   r  r   r   r  r  r  r  rX  rR  r  r   r  s     r   )test_get_address_list_group_and_mailboxesz4TestParser.test_get_address_list_group_and_mailboxes,
  s   ''(?(?;;; 	00.A\334a8//%33	5\334a8//2==zJ//2??'	)//2<<Q?FF&	(//2<<Q?JJ 	"//2<<Q?JJ	//2<<Q?JJ	\33A67\33A67	9r   c                 n    | j                  t        j                  dddt        j                  gdz        }y )Nz;attachmentz; attachmentr   )r2   r    parse_content_disposition_headerr   re   )r   content_disps     r    test_invalid_content_dispositionz+TestParser.test_invalid_content_dispositionI
  s3    ))33>=''(*
r   c                 n    | j                  t        j                  dddt        j                  gdz        }y )Nz;foor  )r2   r   &parse_content_transfer_encoding_headerr   re   )r   ctes     r   &test_invalid_content_transfer_encodingz1TestParser.test_invalid_content_transfer_encodingP
  s2      99FFV%?%?$@$B
r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY wr0   rS   r   rT   r   
get_msg_idr=   s    r   test_get_msg_id_emptyz TestParser.test_get_msg_id_emptyX
  s9    v667 	"b!	" 	" 	"rW   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz%<simeple.local@example.something.com>r   msg-idr.   r   r  r   r   r   msg_ids     r   test_get_msg_id_validz TestParser.test_get_msg_id_valid]
  sB    !!333 	**H5r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nz<"simeple.local"@example.com>z<simeple.local@example.com>r   r  r.   r   r  r   rD  r   r   r  s     r   test_get_msg_id_obsolete_localz)TestParser.test_get_msg_id_obsolete_localh
  sK    !!++)(() 	**H5r   c                     | j                  t        j                  dddg d      }| j                  |j                  d       y )Nz&<simple.local@[someexamplecom.domain]>r   r  r  r  s     r   *test_get_msg_id_non_folding_literal_domainz5TestParser.test_get_msg_id_non_folding_literal_domains
  sB    !!444 	**H5r   c                 j    | j                  t        j                  dddt        j                  gd      }y )Nz<simplelocal@(old)example.com>z<simplelocal@ example.com>r   )r.   r   r  r   rD  r  s     r   $test_get_msg_id_obsolete_domain_partz/TestParser.test_get_msg_id_obsolete_domain_part
  s3    !!,,((()
r   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nz<simplelocal>r   r  r.   r   r  r   re   r   r   r  s     r    test_get_msg_id_no_id_right_partz+TestParser.test_get_msg_id_no_id_right_part
  sK    !!''(
 	**H5r   c                     d}t        j                  |      }| j                  |j                  t        j
                  g       y )N3935-XPB-567:0:45327:9:90305:17843586-40@example.com)r   parse_message_idr!   r"   r   re   )r   textr  s      r   1test_get_msg_id_invalid_expected_msg_id_not_foundz<TestParser.test_get_msg_id_invalid_expected_msg_id_not_found
  s:    D((.''(	*r   c                     | j                  t        j                  dddt        j                  g      }| j                  |j                  d       y )Nr&  zinvalid-message-id)r2   r   r'  r   re   r   r   r   
message_ids     r   test_parse_invalid_message_idz(TestParser.test_parse_invalid_message_id
  sI    ''##AAA''(
 	..0DEr   c                     | j                  t        j                  dddg       }| j                  |j                  d       y )Nz<aperson@somedomain>
message-id)r2   r   r'  r   r   r+  s     r   test_parse_valid_message_idz&TestParser.test_parse_valid_message_id
  s?    ''##"""
 	..=r   c                     | j                  t        j                  dddt        j                  gg       }| j                  |j                  d       | j                  t        |j                  d         d       y )Nz%<validmessageid@example>thensomethingz<validmessageid@example>r/  r   zUnexpected 'thensomething')	r2   r   r'  r   re   r   r   r   r"   r+  s     r   $test_parse_message_id_with_remainingz/TestParser.test_parse_message_id_with_remaining
  sn    ''##3&&''(
 	..=Z33A675	7r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nmsgwithnoankler  r=   s    r   test_get_msg_id_no_angle_startz)TestParser.test_get_msg_id_no_angle_start
  :    v667 	0./	0 	0 	0rW   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nz<simplelocal@domainz<simplelocal@domain>r   r  r#  r  s     r   test_get_msg_id_no_angle_endz'TestParser.test_get_msg_id_no_angle_end
  sK    !!!""''(
 	**H5r   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz	<@domain>r  r=   s    r   test_get_msg_id_empty_id_leftz(TestParser.test_get_msg_id_empty_id_left
  r  rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz<simplelocal@>r  r=   s    r   test_get_msg_id_empty_id_rightz)TestParser.test_get_msg_id_empty_id_right
  r6  rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz<simplelocal@r  r=   s    r   test_get_msg_id_no_id_rightz&TestParser.test_get_msg_id_no_id_right
  s9    v667 	/o.	/ 	/ 	/rW   c                     | j                  t        j                        5  t        j                  d       d d d        y # 1 sw Y   y xY w)Nz<[abrakadabra@microsoft.com]>r  r=   s    r   test_get_msg_id_with_bracketsz(TestParser.test_get_msg_id_with_brackets
  s<     v667 	?=>	? 	? 	?rW   c                     | j                  t        j                  dddt        j                  gd      }| j                  |j                  d       y )Nz
< @domain>r   r  r  r  s     r   test_get_msg_id_ws_only_localz(TestParser.test_get_msg_id_ws_only_local
  sK    !!(()
 	**H5r   N(S  r   r   r   bytesr  r   r   r&   ascii_lettersdigitsr&  	translater   	maketransr  r>   rB   rE   rH   rL   rO   rV   rY   r[   r]   rb   rf   ri   rk   ru   rw   rz   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   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r#  r'  r-  r1  r5  r7  r>  r@  rF  rI  rK  rM  rP  rR  rU  rW  rY  r[  r]  rc  re  ri  rm  ro  rr  rt  rv  ry  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  r  r  r  r  r  r	  r  r  r  r  r  r  r  r  r   r%  r'  r*  r-  r6  r=  rE  rI  rO  rQ  rZ  r^  ra  re  rg  ri  rk  rm  rp  rr  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  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  r5  r7  r:  r<  r>  rA  rD  rF  rH  rK  rM  rT  rV  rX  r[  r]  r_  ra  rg  rj  rm  rq  rt  rx  rz  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  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r!  r$  r)  r-  r0  r2  r5  r8  r:  r<  r>  r@  rB  r   r   r   r4   r4   -   s      b#/66w?++fmm;./O)33CMM"R4OPOBDJ0FN
+-/=##1/*&=F---------4
Q9A59;59;E4
C;C7;=E4
?
=E=E?
51J:FF4=.
/$
8
*HH"
:Q=
=4
6
+1A
32
1
21
1
627,,5546:540252
545522&'46:0)11213+R*
2
+/-8:5;/+6B8?H)<BB	D<BC	DBML&-8;;;;CCG	<4
?
=EE%7;=7;=	9990167777777"+3
F	F	F	I	I	O	I@PP8?1>&4G5AG
M
G
G
G
G
G&',2)2FS	L	J	=	F1FFFFFAAFF%,-,DDDD	M5$5 5,5,+<+2+,	1
3)
3
3.
=.1=*?(&6$ $ $ ) ?";";C"	^	M8"P /6"&HF ("9:

"
	6	6	6
	6*F>70	6+0/?	6r   r4   c                   v   e Zd Zd Zddddgg fddddd	gg fd
dd
dgg fddddgej
                  gfddddgej
                  gfddddgej
                  gfddddgej
                  gfddddgej
                  gfddddgej
                  gdz  fddddgej
                  gdz  fddd d!gej
                  gdz  fd"Zy#)$Test_parse_mime_parametersc                     | j                  t        j                  ||||      }| j                  |j                  d       | j                  t        |j                        |       y )Nzmime-parameters)r2   r   parse_mime_parametersr   r   listparams)r   r   tl_strtl_valuerM  r'   mime_parameterss          r   mime_parameters_as_valuez3Test_parse_mime_parameters.mime_parameters_as_value
  sW     ,,V-I-I68W.335FGo445v>r   zfilename="abc.py"z filename="abc.py"zfilename=abc.py)filenamezabc.pyzfilename="abc.py"; xyz=abcz filename="abc.py"; xyz="abc"zfilename=abc.py; xyz=abc)xyzrQ   z;filename*0*=iso-8859-1''%32%30%31%2E; filename*1*=%74%69%66z filename="201.tif")rR  z201.tifz#filename=abc.gif; filename=def.tiffz filename="abc.gif")rR  zabc.gifzMfilename*0*=iso-8859-1''%32%30%31%2E; filename*1*=%74%69%66; filename=abc.gifzNfilename=abc.gif;  filename*0*=iso-8859-1''%32%30%31%2E; filename*1*=%74%69%66zMfilename=abc.gif; filename*0*=iso-8859-1''%32%30%31%2E; filename*1*=%74%69%66zPfilename*0*=iso-8859-1''%32%30%31%2E; filename*1*=%74%69%66; filename*1*=abc.gifz filename="201.tifabc.gif")rR  z201.tifabc.gifz<filename*0*=iso-8859-1''%32%30%31%2E; filename*3*=%74%69%66;zPfilename*0*=iso-8859-1''%32%30%31%2E; filename*3*=%74%69%66; filename*3*=abc.gifr   zNfilename=abc.gif;  filename*2*=iso-8859-1''%32%30%31%2E; filename*3*=%74%69%66z filename="abc.gif201.tif"zMfilename=abc.gif; filename*2*=iso-8859-1''%32%30%31%2E; filename*3*=%74%69%66)rR  zabc.gif201.tifr  z	r*="'a'\"z r="\""zr*='a'")rr  )simplemultiple_keyssplit_valueduplicate_keyduplicate_key_with_split_value*duplicate_key_with_split_value_other_orderduplicate_in_split_valuemissing_split_value!duplicate_and_missing_split_value!duplicate_with_broken_split_valueextra_dquoteN)r   r   r   rQ  r   re   mime_parameters_paramsr   r   r   rI  rI  
  s   	?   #$ )+&#^4 J!I$% 2!1$%''(*$!$$%''(+*O!O$%''(7*'('+,''(%* K!J$%''( *'('+,''(*.,O(O+,''(*., L''(*,ybr   rI  c            
       t    e Zd Zd Zdddddg fdddddg fdddddg fd	d	d
ddg fdddddej
                  gfdZy)Test_parse_mime_versionc                     | j                  t        j                  ||||      }| j                  |j                  |       | j                  |j
                  |       y r    )r2   r   parse_mime_versionr   majorminor)r   r   rN  rO  re  rf  r'   mime_versions           r   mime_version_as_valuez-Test_parse_mime_version.mime_version_as_value`  sQ     ))&*C*C68W.++U3++U3r   z1.0r:   r   z1.0 (produced by MetaSend Vx.x)z1.0 z(produced by MetaSend Vx.x) 1.0z 1.0z1.(produced by MetaSend Vx.x)0z1. 0r   N)
rfc_2045_1
RFC_2045_2
RFC_2045_3
RFC_2045_4empty)r   r   r   rh  r   HeaderMissingRequiredValuemime_version_paramsr   r   r   rb  rb  ]  s    
4  .- .- -, ../1E*
r   rb  c                       e Zd Zej                  Zef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y)TestFoldingc                 f    | j                  |j                  |      ||j                                y )Nr   )r   foldppstr)r   r$   foldedr   s       r   _testzTestFolding._test  s%    /Dr   c                 N    | j                  t        j                  d      d       y )NzThis is a testzThis is a test
rv  r   r   r=   s    r   !test_simple_unstructured_no_foldsz-TestFolding.test_simple_unstructured_no_folds  s    

6**+;<%	'r   c                 N    | j                  t        j                  d      d       y )NzvThis is also a test, but this time there are enough words (and even some symbols) to make it wrap; at least in theory.zxThis is also a test, but this time there are enough words (and even some
 symbols) to make it wrap; at least in theory.
rx  r=   s    r   test_simple_unstructured_foldedz+TestFolding.test_simple_unstructured_folded  s)    

6** ,H IF	Gr   c                 N    | j                  t        j                  d      d       y )Nu   hübsch kleiner beißtz+=?utf-8?q?h=C3=BCbsch_kleiner_bei=C3=9Ft?=
rx  r=   s    r   'test_unstructured_with_unicode_no_foldsz3TestFolding.test_unstructured_with_unicode_no_folds  s     

6**+CDA	Cr   c                 N    | j                  t        j                  d      d       y )NuQ   Mein kleiner Kaktus ist sehr hübsch.  Es hat viele Stacheln und oft beißt mich.zuMein kleiner Kaktus ist sehr =?utf-8?q?h=C3=BCbsch=2E?=  Es hat viele Stacheln
 und oft =?utf-8?q?bei=C3=9Ft?= mich.
rx  r=   s    r   (test_one_ew_on_each_of_two_wrapped_linesz4TestFolding.test_one_ew_on_each_of_two_wrapped_lines  s'    

6** ,B C=	>r   c                 N    | j                  t        j                  d      d       y )NuD   Mein Kaktus ist hübsch.  Es beißt mich.  And that's all I'm sayin.z\Mein Kaktus ist =?utf-8?q?h=C3=BCbsch=2E__Es_bei=C3=9Ft?= mich.  And that's
 all I'm sayin.
rx  r=   s    r   test_ews_combined_before_wrapz)TestFolding.test_ews_combined_before_wrap  s'    

6** ,G H'	(r   c                     | j                  t        j                  d      d       d}| j                  t        j                  |dz         |dz          y )Nu   =?unknown-8bit?q?=A4?=¤z)=?unknown-8bit?q?=A4?==?utf-8?q?=C2=A4?=
70123456789 0123456789 0123456789 0123456789 0123456789 z+=?unknown-8bit?q?=A4?=
 =?utf-8?q?=C2=A4?=
rx  r   prefixs     r   'test_unicode_after_unknown_not_combinedz3TestFolding.test_unicode_after_unknown_not_combined  sN    

6**+GH?	A 

6**64P+PQKK	Mr   c                     | j                  t        j                  d      d       d}| j                  t        j                  |dz         |dz          y )Nz=?unknown-8bit?q?=A4?=abcz=?unknown-8bit?q?=A4?=abc
r  z(=?unknown-8bit?q?=A4?=
 =?utf-8?q?abc?=
rx  r  s     r   %test_ascii_after_unknown_not_combinedz1TestFolding.test_ascii_after_unknown_not_combined  sM    

6**+FG0	2 

6**64O+OPHH	Jr   c                     | j                  t        j                  d      d       d}| j                  t        j                  |dz         |dz          y )Nu   ¤=?unknown-8bit?q?=A4?=z)=?utf-8?q?=C2=A4?==?unknown-8bit?q?=A4?=
r  z+=?utf-8?q?=C2=A4?=
 =?unknown-8bit?q?=A4?=
rx  r  s     r   'test_unknown_after_unicode_not_combinedz3TestFolding.test_unknown_after_unicode_not_combined  sV    

6** ,D E?	A !

6**64P+PQKK	Mr   c                     | j                  t        j                  d      d       d}| j                  t        j                  |dz         |dz          y )Nzabc=?unknown-8bit?q?=A4?=zabc=?unknown-8bit?q?=A4?=
r  zabcd=?unknown-8bit?q?=A4?=zabcd
 =?unknown-8bit?q?=A4?=
rx  r  s     r   %test_unknown_after_ascii_not_combinedz1TestFolding.test_unknown_after_ascii_not_combined  sT    

6** ,D E0	2 !

6**64P+PQ==	?r   c                     | j                  t        j                  d      d       d}| j                  t        j                  |dz         |dz          y )Nz,=?unknown-8bit?q?=C2?==?unknown-8bit?q?=A4?=z=?unknown-8bit?q?=C2=A4?=
r  z/=?unknown-8bit?q?=C2?=
 =?unknown-8bit?q?=A4?=
rx  r  s     r   test_unknown_after_unknownz&TestFolding.test_unknown_after_unknown  s^    

6** ,D E0	2 !

6**6 5D ,D EOO	Qr   c                 T    | j                  t        j                  d      d   d       y )Nzabc <xyz@example.com>r   zabc <xyz@example.com>
rv  r   r  r=   s    r   test_simple_addresszTestFolding.test_simple_address  s$    

6**+BCAF,	.r   c                 T    | j                  t        j                  d      d   d       y )Nzabc <xyz@example.com>, "Fred Blunt" <sharp@example.com>, "J.P.Cool" <hot@example.com>, "K<>y" <key@example.com>, Firesale <cheap@example.com>, <end@example.com>r   zabc <xyz@example.com>, "Fred Blunt" <sharp@example.com>,
 "J.P.Cool" <hot@example.com>, "K<>y" <key@example.com>,
 Firesale <cheap@example.com>, <end@example.com>
r  r=   s    r   #test_address_list_folding_at_commasz/TestFolding.test_address_list_folding_at_commas  s6    

6** ,@ A
 BCDI	Jr   c                 T    | j                  t        j                  d      d   d       y )NuI   Hübsch Kaktus <beautiful@example.com>, beißt beißt <biter@example.com>r   o=?utf-8?q?H=C3=BCbsch?= Kaktus <beautiful@example.com>,
 =?utf-8?q?bei=C3=9Ft_bei=C3=9Ft?= <biter@example.com>
r  r=   s    r   $test_address_list_with_unicode_namesz0TestFolding.test_address_list_with_unicode_names  s/    

6**45568K	Lr   c                 T    | j                  t        j                  d      d   d       y )NuM   "Hübsch Kaktus" <beautiful@example.com>, "beißt" beißt <biter@example.com>r   r  r  r=   s    r   .test_address_list_with_unicode_names_in_quotesz:TestFolding.test_address_list_with_unicode_names_in_quotes   s/    

6**6778:K	Lr   c                     d}| d}| j                  t        j                  |      d   | d       d}d| d}| j                  t        j                  |      d   | d       y )	NzNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@example.comu*   , "Hübsch Kaktus" <beautiful@example.com>r   z:,
 =?utf-8?q?H=C3=BCbsch?= Kaktus <beautiful@example.com>
zO...............................................................................r  u=   " <xyz@example.com>, "Hübsch Kaktus" <beautiful@example.com>zL
 <xyz@example.com>, =?utf-8?q?H=C3=BCbsch?= Kaktus <beautiful@example.com>
r  )r   rT  tos      r   0test_address_list_with_list_separator_after_foldz<TestFolding.test_address_list_with_list_separator_after_fold  s    %s<=

6**2.q1cMN	P PQ

6**2.q1c ( (	)r   c           	      "   t        j                  d      }t        j                  t        j                  t        j                  dd      g      t        j
                  t        j                  dd      g      |g      }| j                  |d       y )NzP   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxztest:r   r@   r   zXtest:   
 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
)r   r   HeaderHeaderLabelValueTerminalCFWSListWhiteSpaceTerminalrv  )r   bodyheaders      r   7test_split_at_whitespace_after_header_before_long_tokenzCTestFolding.test_split_at_whitespace_after_header_before_long_token  st    &&~6 4 4Wg FGHOOV66sEBCDd L M 	

689r   c                 N    | j                  t        j                  d      d       y )NzSxxx   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzUxxx  
 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
rx  r=   s    r   *test_split_at_whitespace_before_long_tokenz6TestFolding.test_split_at_whitespace_before_long_token  s    

6**+<=-	/r   c                     d}d}t        |      dz   }|t        |      z   }| j                  t        j                  |dz         ||z   dd|z
  z  z   dz   dz   |z   dd	d|z
  z
  z  z   dz          y )
Nzxxx   z
=?utf-8?q?r   Pyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyr  N   z?=
r@   P   )r  rv  r   r   )r   first_token_with_whitespacechrome_leader
len_chrome	len_non_ys        r   #test_overlong_encodeable_is_wrappedz/TestFolding.test_overlong_encodeable_is_wrapped#  s    &.#$'!+
%@!AA	

6**+F+1,2 3.>ByL)*,23*+-0"bl2C-DEGMN	Or   c                 N    | j                  t        j                  d      d       y )NzZattachment; filename="TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TES.txt"zvattachment;
 filename*0*=us-ascii''TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST;
 filename*1*=_TEST_TES.txt
)rv  r   r
  r=   s    r   test_long_filename_attachmentz)TestFolding.test_long_filename_attachment.  s'    

6::DE+	r   N)r   r   r   r   defaultrv  ry  r{  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   rq  rq    s}    ^^F'- E'GC>(MJM?Q.	JLL)":/	Or   rq  __main__)r&   unittestemailr   r   r   r   test.test_emailr   r   r
   r   r4   rI  rb  rq  r   mainr   r   r   <module>r     s      0   7	. 	. 2y*6- y*6zU p- p pd 8
o} 8
 8
x\- \| zHMMO r   