o
    HXh(                     @   sp  d dl Z d dlZd dlZd dlZd dlmZ d dlZd dl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-d.d d/gd'd0dgd1ZeeZe D ]ZeD ]Zed2 qqG d3d4 d4ejZG d5d6 d6ejZG d7d8 d8ejZed9kre  dS dS ):    N)	os_helperz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}
   Z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                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
HelperFunctionTestc                 C   s   t  }| |t |D ]}| |t qt %}d|v r'|d tj	}nddg}tj	
||d< t  }W d    n1 sAw   Y  | || d S )NMAILCAPSz/testdir1/.mailcapz/testdir2/mailcap)mailcaplistmailcapfilesassertIsInstanceliststrr   EnvironmentVarGuardsplitospathsepjoinassertEqual)selfZmcfilesmenvZenv_mailcaps r;   ;/opt/python-3.10.19/usr/lib/python3.10/test/test_mailcap.pytest_listmailcapfilesG   s   
	z(HelperFunctionTest.test_listmailcapfilesc              	   C   sn   t td"}| t t|}W d    n1 sw   Y  W d    n1 s*w   Y  | |t d S )Nr)openMAILCAPFILEZassertWarnsDeprecationWarningr-   ZreadmailcapfileassertDictEqualMAILCAPDICT_DEPRECATED)r8   mcfdr;   r;   r<   test_readmailcapfileZ   s   z'HelperFunctionTest.test_readmailcapfilec                 C   s   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MAILCAPDICTZassertListEqualrC   )r8   Zexpectedactualkeyr;   r;   r<   test_lookupa   s"   zHelperFunctionTest.test_lookupc                 C   s   g d}g ddf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 ]}|  tj|d  |d  q4d S )N)zid=1znumber=2ztotal=3)r   r)   foo.txtr   )echo foor)   rL   rM   )zecho %sr)   rL   zecho foo.txt)echo %tr)   rL   )rN   	audio/wavrL   zecho audio/wav)zecho \%tr)   rL   rN   r)   rL   zecho %{total}zecho 3r   r   )r7   r-   subst)r8   plistZ
test_casesZtcr;   r;   r<   
test_substw   s   






zHelperFunctionTest.test_substN)__name__
__module____qualname__r=   rF   rK   rR   r;   r;   r;   r<   r+   E   s
    r+   c                   @   s   e Zd Zdd Zdd ZdS )GetcapsTestc                 C   sJ   t  }t|d< t }| |t W d    d S 1 sw   Y  d S )Nr,   )r   r2   r@   r-   getcapsrB   rH   )r8   r:   capsr;   r;   r<   test_mock_getcaps   s
   
"zGetcapsTest.test_mock_getcapsc                 C   s   t  }| |t t  }dd |D }|r9| D ]\}}| |t | |t |D ]}| |t q-qd S | i | d S )Nc                 S   s   g | ]
}t j|r|qS r;   )r4   pathexists).0rD   r;   r;   r<   
<listcomp>   s    z3GetcapsTest.test_system_mailcap.<locals>.<listcomp>)	r-   rW   r/   dictr.   itemsr1   r0   r7   )r8   rX   ZmailcapfilesZexistingmcfileskver;   r;   r<   test_system_mailcap   s   zGetcapsTest.test_system_mailcapN)rS   rT   rU   rY   rc   r;   r;   r;   r<   rV      s    	rV   c                   @   sH   e Zd Zdd Zeejdkdee	j
dkddd Zd	d
 ZdS )FindmatchTestc           	      C   sB  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| |ff|ddgd|id| |ff|dgd|dd|ff|d gd|idf|d!gd|id"|ff|d#gd$|id%|ffg}| | d S )&NrL   )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   Zfoobarr*   filename)rJ   rf   r)   rO   z"/usr/local/bin/showaudio audio/wavr(   rQ   z?showexternal /dev/null default john python.org     /tmp foo bar)rH   
_run_cases)	r8   cZfnamerQ   Zaudio_basic_entryZaudio_entryZvideo_entryZmessage_entrycasesr;   r;   r<   test_findmatch   s\   


zFindmatchTest.test_findmatchposixz!Requires 'test' command on systemvxworksz*'test' command is not supported on VxWorksc                 C   sL   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/failrm   rn   re   )rg   )r8   rX   ri   r;   r;   r<   	test_test   s   zFindmatchTest.test_testc                 C   s2   |D ]}|  tj|d i |d |d  qd S )Nr   r   r   )r7   r-   Z	findmatch)r8   ri   rh   r;   r;   r<   rg      s   &zFindmatchTest._run_casesN)rS   rT   rU   rj   unittestZ
skipUnlessr4   nameZskipIfsysplatformro   rg   r;   r;   r;   r<   rd      s    6rd   __main__)r-   r4   copyZtest.supportr   r   rp   rr   supportZfindfiler@   rH   deepcopyrC   valuesZ
entry_listentrypopZTestCaser+   rV   rd   rS   mainr;   r;   r;   r<   <module>   sr    








1CP