
    daf-                     v   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                  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j!                         D ]  ZeD ]  Zej'                  d4          G d5 d6ej(                        Z G d7 d8ej(                        Z G d9 d:ej(                        Zed;k(  r ej2                          yy)<    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y)HelperFunctionTestc                    t         j                         }| j                  |t               |D ]  }| j                  |t                t        j                         5 }d|v r#|d   j                  t        j                        }n:ddg}t        j                  j                  |      |d<   t         j                         }d d d        | j                  |       y # 1 sw Y   xY w)NMAILCAPSz/testdir1/.mailcapz/testdir2/mailcap)r   listmailcapfilesassertIsInstanceliststrr   EnvironmentVarGuardsplitospathsepjoinassertEqual)selfmcfilesmenvenv_mailcapss        ,/root/Python-3.12.4/Lib/test/test_mailcap.pytest_listmailcapfilesz(HelperFunctionTest.test_listmailcapfilesK   s     **,gt, 	*A!!!S)	***, 	5 S ":44RZZ@ 46IJ"$**//,"?J!224	5 	w/	5 	5s   A"CC"c                     t        t        d      5 }| j                  t              5  t        j                  |      }d d d        d d d        | j                  t               y # 1 sw Y   (xY w# 1 sw Y   ,xY w)Nr)openMAILCAPFILEassertWarnsDeprecationWarningr   readmailcapfileassertDictEqualMAILCAPDICT_DEPRECATED)r=   mcfds      rB   test_readmailcapfilez'HelperFunctionTest.test_readmailcapfile^   sj    +s# 	1s!!"45 1++C01	1 	Q 671 1	1 	1s!   A0A$A0$A-	)A00A9c                 H   ddddddg}t         j                  t        d      }| j                  ||       d}ddd	d
ddg}t         j                  t        d|      }| j                  ||       ddiddig}t         j                  t        d      }| j                  ||       y )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_lookupe   s    )R8+r:<\:Xv. . 1$9+ 	" #
 ]C@Xv. ^,v|.DE 6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 ]*  }| j                  t        j                  |d    |d          , y )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    / (,/<.?02BC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   I   s    0&8/,;rX   r0   c                       e Zd Zd Zd Zy)GetcapsTestc                     t        j                         5 }t        |d<   t        j	                         }| j                  |t               d d d        y # 1 sw Y   y xY w)Nr2   )r   r7   rG   r   getcapsrK   rR   )r=   r@   capss      rB   test_mock_getcapszGetcapsTest.test_mock_getcaps   sL     **, 	4)C
O??$D  {3	4 	4 	4s   4AAc                    t         j                         }| j                  |t               t         j	                         }|D cg c]$  }t
        j                  j                  |      s#|& }}|rb|j                         D ]N  \  }}| j                  |t               | j                  |t               |D ]  }| j                  |t                P y | j                  i |       y c c}w )N)r   rk   r4   dictr3   r9   pathexistsitemsr6   r5   r<   )r=   rl   mailcapfilesrM   existingmcfileskves           rB   test_system_mailcapzGetcapsTest.test_system_mailcap   s     dD)//1*6N3"''..:M3NN**, 3A%%a-%%a. 3A))!T233 R& Os   $C%(C%N)rd   re   rf   rm   rx   rg   rX   rB   ri   ri      s    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y
)FindmatchTestc                 V   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}| j                  |       y )%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+r:+Qdfg	
 ,\2^R.%8+$FG'.FHY-Z[	*B1IK\0]^.5JL]4^_)2|<^j%0<%3G2UV	*% %'):;= "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                 d    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}| j                  |       y )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   sd      &~67%~679 K("~?W.XYK("l;	
 	rX   c                 F   | j                  t        j                  d      5  t        j                  ddddg      }| j	                  |d        d d d        | j                  t        j                  d      5  t        j                  ddd      }| j	                  |d        d d d        | j                  t        j                  d	      5  t        j                  t        dd
      }| j	                  |d       d d d        y # 1 sw Y   xY w# 1 sw Y   mxY w# 1 sw Y   y xY w)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 #==)4)2*36L \40	1 ""7#=#=$45 	4 &mmIy)LO_d3		4 ""7#=#=$DE 	< &//0;9C 0 EO _l;	< 	<	1 	1	4 	4	< 	<s#   ,C?5*D/D?DDD c           	      n    |D ]0  }| j                  t        j                  |d   i |d   |d          2 y )Nr   r   r   )r<   r   r   )r=   r   r   s      rB   r   zFindmatchTest._run_cases  s?     	EAW..!=!=qtD	ErX   N)rd   re   rf   r   unittest
skipUnlessr9   nameskipIfsysplatformr"   supporthas_subprocess_supportr   r   r   rg   rX   rB   rz   rz      s    1f XG+-PQX__S\\Y.0\]X++/	 ^ R"<0ErX   rz   __main__)copyr9   r   test.supportr"   r   r   r   import_deprecatedr   r   findfilerG   rR   deepcopyrL   values
entry_listentrypopTestCaser0   ri   rz   rd   mainrg   rX   rB   <module>r      s    	 
   " ( ,/
+
+I
6 ll##M2 %<""	
 	 W
 	 $&. 	
 	 !B	/0':a	H)<	J	L q	)*)Oe	
 	 X=
 	
 !	,-/1	=>"	-."Na	HI!	,-Y-b '{3 (//1 J 		(
?;** ?;D'(## ':fEH%% fER zHMMO rX   