
    5\h-                     r   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ  ej	        d          Z
ej                            d          Zdddd	d
dgddddgddddddgdddgddddddddgdddgd d!dd"d#d$gd%dd&d'd(gd)d*dgd+d,dgd-d.dgd/d0d d1gd)d2dgd3Z e j        e          Ze                                D ]ZeD ]Ze                    d4            G d5 d6ej                  Z G d7 d8ej                  Z G d9 d:ej                  Zed;k    r ej                     dS dS )<    N)	os_helper)warnings_helpermailcapzmailcap.txtzmoviemaker %sz""/usr/lib/Zmail/bitmaps/movie.xbm"z"Movie"zmovieplayer %s   )composez
x11-bitmapdescriptionviewlineno z?echo "This is \"%t\" but        is 50 \% Greek to me" \; cat %s   )copiousoutputr	   r
   audiocompose %s"An audio fragment"showaudio %s   editr   r   r	   r
   mpeg_play %s   r	   r
   zps-to-terminal %s   )needsterminalr	   r
   zidraw %s   )r   r	   r
   zxdvi %s   extcompose %s4"A reference to data stored in an external location"Qshowexternal %s %{access-type} %{name} %{site}     %{directory} %{mode} %{server}
   composetypedr   r   r	   r
   z?test "`echo     %{charset} | tr '[A-Z]' '[a-z]'`"  = iso-8859-8z)shownonascii iso-8859-8 -e richtext -p %s   )testr   r	   r
   z
display %s	   /usr/local/bin/showaudio %t   
animate %s   z"cat %s | lp"zshowframe %s)printr	   r
      )zapplication/x-moviezapplication/*audio/basic
video/mpegzapplication/postscriptzapplication/x-dvimessage/external-bodyztext/richtextzimage/x-xwindowdumpaudio/*video/*zapplication/framez	image/rgbr
   c                   &    e Zd Zd Zd Zd Zd ZdS )HelperFunctionTestc                    t                                           }|                     |t                     |D ]}|                     |t                     t          j                    5 }d|v r&|d                             t          j	                  }n?ddg}t          j	        
                    |          |d<   t                                           }d d d            n# 1 swxY w Y   |                     ||           d S )NMAILCAPSz/testdir1/.mailcapz/testdir2/mailcap)r   listmailcapfilesassertIsInstanceliststrr   EnvironmentVarGuardsplitospathsepjoinassertEqual)selfmcfilesmenvenv_mailcapss        ;/opt/python-3.11.14/usr/lib/python3.11/test/test_mailcap.pytest_listmailcapfilesz(HelperFunctionTest.test_listmailcapfilesL   s-    **,,gt,,, 	* 	*A!!!S))))*,, 	5 S  ":44RZ@@ 46IJ"$*//,"?"?J!2244	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	w/////s   (A*CC"%C"c                 .   t          t          d          5 }|                     t                    5  t                              |          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     |t                     d S )Nr)openMAILCAPFILEassertWarnsDeprecationWarningr   readmailcapfileassertDictEqualMAILCAPDICT_DEPRECATED)r=   mcfds      rB   test_readmailcapfilez'HelperFunctionTest.test_readmailcapfile_   s    +s## 	1s!!"455 1 1++C001 1 1 1 1 1 1 1 1 1 1 1 1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	Q 677777s4   A/AA/A	A/A	 A//A36A3c                    ddddddg}t                               t          d          }|                     ||           d}ddd	d
ddg}t                               t          d|          }|                     ||           ddiddig}t                               t          d          }|                     ||           d S )Nr&   r'   r   r   r   r+   r   r   r   r   r   r   r*   r	   )r   lookupMAILCAPDICTassertListEqualrL   )r=   expectedactualkeys       rB   test_lookupzHelperFunctionTest.test_lookupf   s    )R88+r::<\::Xv... . 1$9+ 	" " #
 ]C@@Xv... ^,v|.DE 6EEXv.....    c           
          g d}g ddfg ddfg ddfg dd	fg d
dfddd|gdfddd|gdfg}|D ]0}|                      t          j        |d          |d                    1d S )N)zid=1znumber=2ztotal=3)r   r-   foo.txtr   )echo foor-   rZ   r[   )zecho %sr-   rZ   zecho foo.txt)echo %t	audio/wavrZ   zecho audio/wav)zecho \%tr-   rZ   r\   r-   rZ   echo %{total}zecho 3r   r   )r<   r   subst)r=   plist
test_casestcs       rB   
test_substzHelperFunctionTest.test_subst|   s    /// ('',///<...?0002BC000)<)Y6
Cy)U;XF

  	; 	;BW]BqE2BqE::::	; 	;rX   N)__name__
__module____qualname__rC   rO   rW   rc    rX   rB   r0   r0   J   sP        0 0 0&8 8 8/ / /,; ; ; ; ;rX   r0   c                       e Zd Zd Zd ZdS )GetcapsTestc                     t          j                    5 }t          |d<   t                                          }|                     |t                     d d d            d S # 1 swxY w Y   d S )Nr2   )r   r7   rG   r   getcapsrK   rR   )r=   r@   capss      rB   test_mock_getcapszGetcapsTest.test_mock_getcaps   s     *,, 	4)C
O??$$D  {333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   ?A  A$'A$c                    t                                           }|                     |t                     t                                           }d |D             }|rr|                                D ][\  }}|                     |t                     |                     |t                     |D ]}|                     |t                     \d S |                     i |           d S )Nc                 P    g | ]#}t           j                            |          !|$S rg   )r9   pathexists).0rM   s     rB   
<listcomp>z3GetcapsTest.test_system_mailcap.<locals>.<listcomp>   s+    NNN3"'..:M:MN3NNNrX   )	r   rk   r4   dictr3   itemsr6   r5   r<   )r=   rl   mailcapfilesexistingmcfileskves          rB   test_system_mailcapzGetcapsTest.test_system_mailcap   s      dD)))//11NN,NNN 		'**,, 3 3A%%a---%%a... 3 3A))!T222233 3 R&&&&&rX   N)rd   re   rf   rm   r{   rg   rX   rB   ri   ri      s2        4 4 4' ' ' ' 'rX   ri   c                       e Zd Zd Z ej        ej        dk    d           ej        e	j
        dk    d           ej        ej        j        d          d                                     Zd Zd	 Zd
S )FindmatchTestc                 b   t           }d}g d}dddddd}dd	d
}ddd
}dddddd}i dgi df|dgi df|dgi d|ff|ddgi d|ff|ddgi d|ff|ddgi d|ff|ddgi df|dgd|id|z  |ff|ddgd|id|z  |ff|dgd|dd|ff|d gd|id!|ff|d"gd#|id$|ffg}|                     |           d S )%NrZ   )zaccess-type=defaultz	name=johnzsite=python.orgzdirectory=/tmpzmode=fooz
server=barr   r   r   r   r   r$   r%   r   r&   r'   r   r   r   r   r   r   r+   NNzfoo/barzanimate /dev/nullr*   r   zaudiocompose /dev/nullr   r   foobarr.   filename)rV   r   r]   z"/usr/local/bin/showaudio audio/wavr,   r`   z?showexternal /dev/null default john python.org     /tmp foo bar)rR   
_run_cases)	r=   cfnamer`   audio_basic_entryaudio_entryvideo_entrymessage_entrycasess	            rB   test_findmatchzFindmatchTest.test_findmatch   s    = = = &(0"
 
  =JJ+r::+Qdfg	
 
 ,\2^R.%8+$FG'.FHY-Z[	*B1IK\0]^.5JL]4^_)2|<^j%0<%3G2UV	*% %'):;= "66#%679 % 2K@B ()uOQ^_a%
, 	rX   posixz!Requires 'test' command on systemvxworksz*'test' command is not supported on VxWorksz%'test' command needs process support.c                 n    ddigddigd}|ddgi dddiff|ddgi dfg}|                      |           d S )Nr"   ztest 1 -eq 1ztest 1 -eq 0)	test/pass	test/failr   r   r   )r   )r=   rl   r   s      rB   	test_testzFindmatchTest.test_test   su      &~67%~679 9 K("~?W.XYK("l;	
 	rX   c                    |                      t          j        d          5  t                              ddddg          }|                     |d            d d d            n# 1 swxY w Y   |                      t          j        d          5  t                              ddd          }|                     |d            d d d            n# 1 swxY w Y   |                      t          j        d	          5  t                              t          dd
          }|                     |d           d d d            d S # 1 swxY w Y   d S )Nz6Refusing to substitute parameter.*into a shell commandr^   r]   rZ   ztotal=*z.Refusing to substitute MIME type.*into a shellr\   r-   zERefusing to use mailcap with filename.*Use a safe temporary filename.zfoo*.txt)r   r   )assertWarnsRegexr   UnsafeMailcapInputr_   r<   	findmatchrR   )r=   unsafe_paramunsafe_mimetypeunsafe_filenames       rB   test_unsafe_mailcap_inputz'FindmatchTest.test_unsafe_mailcap_input   s   ""7#=$:; ; 	1 	1 #==)4)2*36 6L \4000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 ""7#=$45 5 	4 	4 &mmIy)LLO_d333		4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 ""7#=$DE E 	< 	< &//0;9C 0 E EO _l;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s5   5A""A&)A&3CCC79D==EEc           	      ~    |D ]9}|                      t          j        |d         i |d         |d                    :d S )Nr   r   r   )r<   r   r   )r=   r   r   s      rB   r   zFindmatchTest._run_cases  sT     	E 	EAW.!=!==qtDDDD	E 	ErX   N)rd   re   rf   r   unittest
skipUnlessr9   nameskipIfsysplatformr"   supporthas_subprocess_supportr   r   r   rg   rX   rB   r}   r}      s        1 1 1f XG+-PQQX_S\Y.0\]]X+/  	  ^] RQ"< < <0E E E E ErX   r}   __main__)copyr9   r   test.supportr"   r   warningsr   r   import_deprecatedr   r   findfilerG   rR   deepcopyrL   values
entry_listentrypopTestCaser0   ri   r}   rd   mainrg   rX   rB   <module>r      s    				 



       " " " " " " ( ( ( ( ( ( ,/
+I
6
6 l##M22 %<""	
 
 	 W
 
 	 $&. 	
 
 	 !B	/	/0':a	H	H)<	J	J	L q	)	)*)Oe	
 
 	 X=
 
 	
 !	,	,-/1	=	=>"	-	-."Na	H	HI!	,	,-Y- -b '{33 (//11  J  		(?; ?; ?; ?; ?;* ?; ?; ?;D' ' ' ' '(# ' ' ':fE fE fE fE fEH% fE fE fER zHMOOOOO rX   