a
    åze·
  ã                   @   sŠ   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZmZ eƒ  ejdddG d	d
„ d
ejƒƒZedkr†e ¡  dS )é    N)Úsupport)Úhashlib_helper)Úassert_python_okÚassert_python_failure)Ú
scriptsdirÚskip_if_missingÚmd5T)Zopensslc                   @   s\   e Zd Zedd„ ƒZe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 )ÚMD5SumTestsc                 C   st   t j td¡| _t  tj¡ t j tjd¡| _t	| jdƒ}| 
d¡ W d   ƒ n1 sZ0    Y  d| _d| _d S )Nz	md5sum.pyzmd5sum.fodderÚwbs   md5sum
test file
s    d38dae2eb1ab346a292ef6850f9e1a0ds    a8b07894e2ca3f2a4c3094065fa6e0a5)ÚosÚpathÚjoinr   ÚscriptÚmkdirr   ÚTESTFN_ASCIIÚfodderÚopenÚwriteÚ
fodder_md5Úfodder_textmode_md5)ÚclsÚf© r   ú1/usr/lib/python3.9/test/test_tools/test_md5sum.pyÚ
setUpClass   s    (zMD5SumTests.setUpClassc                 C   s   t  t j¡ d S )N)r   Úrmtreer   )r   r   r   r   ÚtearDownClass   s    zMD5SumTests.tearDownClassc                 C   s:   t | jƒ\}}}|  |d¡ |  | d¡¡ |  |¡ d S )Nr   s(   d41d8cd98f00b204e9800998ecf8427e <stdin>)r   r   ÚassertEqualÚ
assertTrueÚ
startswithÚassertFalse©ÚselfÚrcÚoutÚerrr   r   r   Útest_noargs   s    ÿzMD5SumTests.test_noargsc                 C   sf   t | j| jƒ\}}}|  |d¡ |  | | j¡¡ | j tj	j
¡D ]}|  | ¡ |¡ qB|  |¡ d S )Nr   )r   r   r   r   r   r   r   Úsplitr   r   ÚsepÚassertInÚencoder    )r"   r#   r$   r%   Úpartr   r   r   Útest_checksum_fodder%   s    z MD5SumTests.test_checksum_fodderc                 C   sl   t | jd| jƒ\}}}|  |d¡ |  | j|¡ | j tjj	¡}|  |d  
¡ |¡ |  |d  
¡ |¡ d S )Nz-lr   éÿÿÿÿéþÿÿÿ)r   r   r   r   r)   r   r'   r   r   r(   r*   ÚassertNotIn)r"   r#   r$   r%   Úpartsr   r   r   Útest_dash_l-   s    zMD5SumTests.test_dash_lc                 C   sF   t | jd| jƒ\}}}|  |d¡ |  | | j¡¡ |  | j|¡ d S )Nz-tr   )	r   r   r   r   r   r   r   r/   r   r!   r   r   r   Útest_dash_t5   s    zMD5SumTests.test_dash_tc                 C   s6   t | jdd| jƒ\}}}|  |d¡ |  | j|¡ d S )Nz-sZ512r   )r   r   r   r   r)   r   r!   r   r   r   Útest_dash_s;   s    zMD5SumTests.test_dash_sc                 C   sJ   t | j| j| jƒ\}}}|  |d¡ | ¡ }|  t|ƒd¡ | j|Ž  d S )Nr   é   )r   r   r   r   Ú
splitlinesÚlen)r"   r#   r$   r%   Úlinesr   r   r   Útest_multiple_files@   s
    zMD5SumTests.test_multiple_filesc                 C   s:   t | jdƒ\}}}|  |d¡ |  |d¡ |  |d¡ d S )Nz-hr4   ó    )r   r   r   ZassertGreaterr!   r   r   r   Ú
test_usageG   s    zMD5SumTests.test_usageN)Ú__name__Ú
__module__Ú__qualname__Úclassmethodr   r   r&   r,   r1   r2   r3   r8   r:   r   r   r   r   r	      s   
	
r	   Ú__main__)Úsysr   ZunittestÚtestr   Ztest.supportr   Ztest.support.script_helperr   r   Ztest.test_toolsr   r   Zrequires_hashdigestZTestCaser	   r;   Úmainr   r   r   r   Ú<module>   s   ?