B
    u9aC                 @   s~   d Z ddlZddlZddlZddlmZmZmZmZ G dd dejZ	G dd dejZ
G dd	 d	ejZed
krze  dS )z"Test cases for the fnmatch module.    N)fnmatchfnmatchcase	translatefilterc               @   sR   e Zd ZdefddZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd ZdS )FnmatchTestCaseTc             C   s>   |r |  |||d||f  n| |||d||f  d S )Nzexpected %r to match pattern %rz#expected %r not to match pattern %r)Z
assertTrueZassertFalse)selffilenamepatternZshould_matchfn r   "/usr/lib/python3.7/test_fnmatch.pycheck_match   s    zFnmatchTestCase.check_matchc             C   s   | j }|dd |dd |dd |dd |dd |dd |dd |dd |dd	d
 |ddd
 |ddd
 |dd |dd |ddd
 |dd |dd |ddd
 |dd d S )Nabcz?*?z???*z*???z???*zab[cd]zab[!de]zab[de]Faz??b\z[\]z[!\]zfoo
barzfoo*zfoo
bar
z
foo
)r   )r   checkr   r   r   test_fnmatch   s&    











zFnmatchTestCase.test_fnmatchc             C   sD   |  ttdd |  ttdd |  ttdd |  ttdd d S )Ntest   *s   testr   )assertRaises	TypeErrorr   r   )r   r   r   r   test_mix_bytes_str0   s    z"FnmatchTestCase.test_mix_bytes_strc             C   sz   | j }|dddt |dddt |dddt |dddt |dddt |dddt |dddt |dddt d S )Nr   TAbCFzusr/binzusr\bin)r   r   )r   r   r   r   r   test_fnmatchcase6   s    z FnmatchTestCase.test_fnmatchcasec             C   s(   |  dd |  dd |  dd d S )Ns   tests   te*s   tests   te*s   foo
bars   foo*)r   )r   r   r   r   
test_bytesB   s    zFnmatchTestCase.test_bytesc             C   sN   t jdt jdk}| j}|dd |dd| |dd| |dd d S )NABCr   r   )ospathnormcaser   )r   
ignorecaser   r   r   r   	test_caseG   s    
zFnmatchTestCase.test_casec             C   sN   t jdt jdk}| j}|dd |dd| |dd| |dd d S )Nr   /zusr/binzusr\bin)r   r    r!   r   )r   normsepr   r   r   r   test_sepO   s    
zFnmatchTestCase.test_sepc          	   C   sf   t  T t dt | j}|dd |dd |dd |dd	 |d
d |dd W d Q R X d S )Nerror[z[[]&z[a&&b]|z[a||b]~z[a~~b],z[a-z+--A-Z].z[a-z--/A-Z])warningscatch_warningssimplefilterWarningr   )r   r   r   r   r   test_warningsW   s    





zFnmatchTestCase.test_warningsN)__name__
__module____qualname__r   r   r   r   r   r   r#   r&   r2   r   r   r   r   r   	   s   
r   c               @   s   e Zd Zdd ZdS )TranslateTestCasec             C   s   |  tdd |  tdd |  tdd |  tdd |  td	d
 |  tdd |  tdd |  tdd d S )Nr   z	(?s:.*)\Z?z(?s:.)\Zza?b*z(?s:a.b.*)\Zz[abc]z(?s:[abc])\Zz[]]z
(?s:[]])\Zz[!x]z(?s:[^x])\Zz[^x]z(?s:[\^x])\Zz[xz
(?s:\[x)\Z)assertEqualr   )r   r   r   r   test_translatee   s    z TranslateTestCase.test_translateN)r3   r4   r5   r9   r   r   r   r   r6   c   s   r6   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
FilterTestCasec             C   s@   |  tddddgdddg |  tdddd	gd
ddg d S )NPythonZRubyZPerlZTclzP*s   Pythons   Rubys   Perls   Tcls   P*)r8   r   )r   r   r   r   test_filterr   s    
zFilterTestCase.test_filterc             C   s(   |  ttdgd |  ttdgd d S )Nr   r   s   testr   )r   r   r   )r   r   r   r   r   x   s    z!FilterTestCase.test_mix_bytes_strc             C   sh   t jdt jdk}| tdddgd|r6ddgndg | tdddgd|r\ddgndg d S )NPpzTest.pyzTest.rbzTest.PLz*.p*z*.P*)r   r    r!   r8   r   )r   r"   r   r   r   r#   |   s
    zFilterTestCase.test_casec             C   sh   t jdt jdk}| tdddgd|r6ddgndg | tdddgd|r\ddgndg d S )Nr   r$   zusr/binZusrzusr\libzusr/*zusr\*)r   r    r!   r8   r   )r   r%   r   r   r   r&      s
    zFilterTestCase.test_sepN)r3   r4   r5   r<   r   r#   r&   r   r   r   r   r:   p   s   r:   __main__)__doc__Zunittestr   r.   r   r   r   r   ZTestCaser   r6   r:   r3   mainr   r   r   r   <module>   s   Z