Your IP : 216.73.216.52


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_filecmp.cpython-310.opt-1.pyc

o

0�iN)�@s|ddlZddlZddlZddlZddlZddlmZddlmZGdd�dej	�Z
Gdd�dej	�Zedkr<e�
�dSdS)	�N)�support)�	os_helperc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FileCompareTestCasec	Cs�tj|_tjd|_tjd|_d}|j|j|jfD]}t|ddd��
}|�|�Wd�n1s3wYqt|jddd��
}|�d�Wd�n1sQwYt��|_	dS)	Nz-samez-diff�Contents of file go here.
�w�utf-8��encodingza+zAn extra line.
)
rZTESTFN�name�	name_same�	name_diff�open�write�tempfile�
gettempdir�dir)�self�datar
�output�r�8/opt/alt/python310/lib64/python3.10/test/test_filecmp.py�setUps���zFileCompareTestCase.setUpcCs(t�|j�t�|j�t�|j�dS�N)�os�unlinkr
rr�rrrr�tearDownszFileCompareTestCase.tearDowncCsl|�t�|j|j�d�|�tj|j|jdd�d�|�t�|j|j�d�|�tj|j|jdd�d�dS)NzComparing file to itself failsF�Zshallowz&Comparing file to identical file fails)�
assertTrue�filecmp�cmpr
rrrrr�
test_matchings����z!FileCompareTestCase.test_matchingcCs4|�t�|j|j�d�|�t�|j|j�d�dS)Nz!Mismatched files compare as equalz#File and directory compare as equal)�assertFalserr r
rrrrrr�test_different(s��z"FileCompareTestCase.test_differentcCsJtj|j|jdd�}tj|j|jdd�}t��|�ttj�dkd�dS)NFrrz+Cache not cleared after calling clear_cache)	rr r
rrZclear_cacher�len�_cache)rZ
first_compareZsecond_comparerrr�test_cache_clear.s�z$FileCompareTestCase.test_cache_clearN)�__name__�
__module__�__qualname__rrr!r#r&rrrrrs

rc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�DirCompareTestCasec	CsVt��}tj�|d�|_tj�|d�|_tj�|d�|_tj�|jd�|_tj�	d�tj�	d�k|_
d}|j|j|j|jfD]G}t�|d�t�
|�tj�|d	�}t�
|�|j
rb||jurbd
}nd}ttj�||�dd
d��
}|�|�Wd�n1s�wYq>ttj�|jd�dd
d��}|�d�Wd�dS1s�wYdS)Nrzdir-samezdir-diff�.hg�A�arT�subdir�FiLe�filerrr�file2zAn extra file.
)rrr�path�joinr�dir_same�dir_diffZdir_ignored�normcase�caseinsensitive�shutil�rmtree�mkdirr
r)rZtmpdirrrZsubdir_path�fnrrrrr6s,

��"�zDirCompareTestCase.setUpcCs$|j|j|jfD]}t�|�qdSr)rr4r5r8r9)rrrrrrQs�zDirCompareTestCase.tearDowncCs|�dtj�dS)Nr+)ZassertInrZDEFAULT_IGNORESrrrr�test_default_ignoresUsz'DirCompareTestCase.test_default_ignorescCs|�t�|j|jdg�dgggfkd�|�t�|j|jdg�dgggfkd�|�tj|j|jdgdd�dgggfkd�|�tj|j|jdgdd�d�ttj�|jd�ddd	��
}|�	d
�Wd�n1skwY|�
t�|j|jddg�dgdggfkd�dS)Nr0z#Comparing directory to itself failsz!Comparing directory to same failsFrr1rrr�Different contents.
z&Comparing mismatched directories fails)rrZcmpfilesrr4r
rr2r3rr")rrrrr�
test_cmpfilesXs@
��
���
��������z DirCompareTestCase.test_cmpfilescCs|�t|�t|��dS)z0Assert that two lists are equal, up to ordering.N)�assertEqual�sorted)rZactualZexpectedrrr�
_assert_listsssz DirCompareTestCase._assert_listscCs�|j|j}}t�||�}|�|j|�|�|j|�|jr1|�|j	ddg�|�|j
ddg�n|�|j	ddg�|�|j
ddg�|�|jddg�|�|jdg�|�|j
g�|�|jg�|�|jdg�|�|jg�d�|j|j�ddg}|�|j|�|j|j}}t�||�}|�|j|�|�|j|�|�|j	ddg�|�|j
gd��|�|jddg�|�|jdg�|�|j
g�|�|jdg�|�|jdg�|�|jg�d�|j|j�d	�|j�ddg}|�|j|�|j|j}}t�tj�|jd�tj�|jd��t�||�}|�|j|�|�|j|�|�|j	gd��|�|j
ddg�|�|jddg�|�|j
dg�|�|jg�|�|jdg�|�|jg�d�|j|j�d	�|j�ddg}|�|j|�ttj�|jd�d
dd��
}|�d
�Wd�n	1�s�wYt�|j|j�}|�|jdg�|�|jdg�d�|j|j�dddg}|�|j|�dS)Nr0r.r/�
diff {} {}�Identical files : ['file']�"Common subdirectories : ['subdir'])r0r1r.r1zOnly in {} : ['file2']rrrr=zDiffering files : ['file2'])rr4r�dircmpr?�left�rightr7rAZ	left_listZ
right_list�commonZcommon_dirsZ	left_onlyZ
right_onlyZ
same_filesZ
diff_files�format�_assert_reportZreportr5r8Zmoverr2r3r
r)r�left_dir�	right_dir�d�expected_reportrrrr�test_dircmpxs��
��
���zDirCompareTestCase.test_dircmpcCsXGdd�dtj�}||j|j�}|j}|�t|���dg�|d}|�t|�|�dS)z/Check that dircmp.subdirs respects subclassing.c@seZdZdS)z=DirCompareTestCase.test_dircmp_subdirs_type.<locals>.MyDirCmpN)r'r(r)rrrr�MyDirCmp�srPr.N)	rrErr5Zsubdirsr?�list�keys�type)rrPrMZsub_dirsZsub_dcmprrr�test_dircmp_subdirs_type�sz+DirCompareTestCase.test_dircmp_subdirs_typecC�j|j|j}}t�||�}tj�|d�}tj�|d�}d�|j|j�dddd�||�g}|�|j	|�dS�Nr.rBrCrD�)
rr4rrErr2r3rIrJZreport_partial_closure�rrKrLrMZleft_subdirZright_subdirrNrrr�test_report_partial_closure��
�z.DirCompareTestCase.test_report_partial_closurecCrUrV)
rr4rrErr2r3rIrJZreport_full_closurerXrrr�test_report_full_closure�rZz+DirCompareTestCase.test_report_full_closurecCsRt���}|�|�����d�}|�||�Wd�dS1s"wYdS)N�
)rZcaptured_stdout�getvalue�strip�splitr?)rZ
dircmp_reportZexpected_report_lines�stdoutZreport_linesrrrrJ�s

"�z!DirCompareTestCase._assert_reportN)
r'r(r)rrr<r>rArOrTrYr[rJrrrrr*5sT
r*�__main__)rrr8rZunittest�testrZtest.supportrZTestCaserr*r'�mainrrrr�<module>s*E�