Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib64/python3.10/distutils/tests/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/distutils/tests/__pycache__/test_filelist.cpython-310.pyc

o

0�i�,�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZdd	lmZmZdd
lmZdZdd
�ZGdd�dejej�ZGdd�dej�Zdd�Zedkrmee��dSdS)zTests for distutils.filelist.�N)�debug)�WARN)�DistutilsTemplateError)�
glob_to_re�translate_pattern�FileList)�filelist)�	os_helper)�captured_stdout�run_unittest)�supportz�include ok
include xo
exclude xo
include foo.tmp
include buildout.cfg
global-include *.x
global-include *.txt
global-exclude *.tmp
recursive-include f *.oo
recursive-exclude global *.x
graft dir
prune dir3
cCs|�dtj�S)z"Converts '/' in a string to os.sep�/)�replace�os�sep)�s�r�D/opt/alt/python310/lib64/python3.10/distutils/tests/test_filelist.py�make_local_pathsrc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�FileListTestCasecCs|�|�t�g�|��dS�N)�assertEqual�get_logsr�
clear_logs��selfrrr�assertNoWarnings'sz!FileListTestCase.assertNoWarningscCs"|�t|�t��d�|��dS)Nr)Z
assertGreater�lenrrrrrrr�assertWarnings+szFileListTestCase.assertWarningscCsJtj}tjdkrt�tj�}dD]\}}|d|i}|�t|�|�qdS)N�\))zfoo*z(?s:foo[^%(sep)s]*)\Z)zfoo?z(?s:foo[^%(sep)s])\Z)zfoo??z(?s:foo[^%(sep)s][^%(sep)s])\Z)zfoo\\*z(?s:foo\\\\[^%(sep)s]*)\Z)zfoo\\\*z(?s:foo\\\\\\[^%(sep)s]*)\Z)zfoo????z2(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z)zfoo\\??z"(?s:foo\\\\[^%(sep)s][^%(sep)s])\Zr)rr�re�escaperr)rrZglob�regexrrr�test_glob_to_re/s

�z FileListTestCase.test_glob_to_recCs�t�}t}ddddd|d�|d�|d�|d	�|d
�|d�|d�|d
�|d�|d�g|_t�d�D]}|��dkr9q0|�|�q0ddd|d�|d�|d�|d�|d�|d
�g	}|�|j|�dS)Nzfoo.tmp�okZxozfour.txtzbuildout.cfgz.hg/last-message.txtzglobal/one.txtzglobal/two.txtzglobal/files.xzglobal/here.tmpzf/o/f.ooz
dir/graft-onezdir/dir2/graft2zdir3/okzdir3/sub/ok.txt�
�)	rr�allfiles�MANIFEST_IN�split�strip�process_template_liner�files)r�	file_list�l�lineZwantedrrr�test_process_template_lineAs<��z+FileListTestCase.test_process_template_linecCs�t�}t��
}|�d�Wd�n1swY|�|��d�dt_z&t��
}|�d�Wd�n1s:wY|�|��d�Wdt_dSdt_w)NZxxxr&Tzxxx
F)rr
Zdebug_printr�getvaluer�DEBUG)rr-�stdoutrrr�test_debug_printis��z!FileListTestCase.test_debug_printcCs*t�}gd�}|�|�|�|j|�dS)N)�a�b�c)r�set_allfilesrr')rr-r,rrr�test_set_allfilesws
z"FileListTestCase.test_set_allfilescCs6t�}gd�|_|��|��|�|jgd��dS)N)r5r6r5�gr7r:)r5r6r7r:)rr,�sortZremove_duplicatesr�rr-rrr�test_remove_duplicates}s

z'FileListTestCase.test_remove_duplicatescCsr|�ttdddd�d��t�d�}|�t|ddd�|�|�ttdddd�d��|�tdddd��d��dS)Nr5TF)ZanchorZis_regex�search�*.pyzfilelist.py)�
assertTrue�hasattrrr �compilerr>)rr"rrr�test_translate_pattern�s$�
����z'FileListTestCase.test_translate_patterncCsdt�}|�|�d��t�}ddg|_|�|�d��t�}ddg|_|�d�|�|jdg�dS)Nr?�a.pyzb.pyza.txt)r�assertFalseZexclude_patternr,r@rr<rrr�test_exclude_pattern�s


z%FileListTestCase.test_exclude_patterncCs�t�}|�g�|�|�d��t�}|�ddg�|�|�d��t�}|�|j�|�ddg�|�d�|�|jddg�dS)Nr?rD�b.txt�*)rr8rEZinclude_patternr@ZassertIsNoner'rr<rrr�test_include_pattern�s

z%FileListTestCase.test_include_patterncCs�t}t�}dD]
}|�t|j|�qt�}|�dd|d�g�|�d�|�|jdg�|��|�d�|�|jdg�|�	�t�}dd|d�g|_|�d�|�|jd|d�g�|��|�d�|�|jd|d�g�|�	�t�}|�dd|d�g�|�d	�|�|jd|d�g�|��|�d
�|�|jd|d�g�|�	�t�}dd|d�g|_|�d�|�|jdg�|��|�d�|�|jdg�|�	�t�}|�d|d
�|d�|d�g�|�d�|�|j|d
�|d�g�|��|�d�|�|j|d
�|d�g�|�	�t�}d|d
�|d�|d�g|_|�d�|�|jd|d�g�|��|�d�|�|jd|d�g�|�	�t�}|�d|d
�|d�|d�g�|�d�|�|j|d
�|d�g�|��|�d�|�|j|d
�|d�g�|�	�t�}d|d
�|d�|d�g|_|�d�|�|jd|d�g�|��|�d�|�|jd|d�g�|�	�dS)N)	ZincludeZexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludeZgraftZpruneZblargrDrGzd/c.pyzinclude *.pyzinclude *.rbzexclude *.pyzexclude *.rbzglobal-include *.pyzglobal-include *.rbzglobal-exclude *.pyzglobal-exclude *.rbzd/b.pyzd/c.txtzd/d/e.pyzrecursive-include d *.pyzrecursive-include e *.pyzrecursive-exclude d *.pyzrecursive-exclude e *.pyzf/f.pyzgraft dzgraft ezprune dzprune e)
rrZassertRaisesrr+r8rr,rr)rr.r-�actionrrr�test_process_template�s��







�



�



z&FileListTestCase.test_process_templateN)�__name__�
__module__�__qualname__rrr#r0r4r9r=rCrFrIrKrrrrr$s(rc@s*eZdZejdd��Zdd�Zdd�ZdS)�FindAllTestCasecCsJt���t�dd�|�t��g�Wd�dS1swYdS)N�foo�bar)r	�temp_cwdr�symlinkrr�findallrrrr�test_missing_symlink*s
"�z$FindAllTestCase.test_missing_symlinkcCs�t���9t�d�tj�dd�}t�|�t�d�tj�dd�}t�|�||g}|�tt	�
��|�Wd�dS1s@wYdS)z�
        When findall is called with no parameters or with
        '.' as the parameter, the dot should be omitted from
        the results.
        rP�	file1.txtrQz	file2.txtN)r	rRr�mkdir�path�join�create_empty_filer�sortedrrT)r�file1Zfile2�expectedrrr�test_basic_discovery0s




"�z$FindAllTestCase.test_basic_discoverycCs^t���!}tj�|d�}t�|�|g}|�t�|�|�Wd�dS1s(wYdS)zj
        When findall is called with another path, the full
        path name should be returned.
        rVN)	r	�temp_dirrrXrYrZrrrT)rr_r\r]rrr�test_non_local_discovery@s

"�z(FindAllTestCase.test_non_local_discoveryN)rLrMrNr	Zskip_unless_symlinkrUr^r`rrrrrO)s

rOcCst�t�t�t�t�g�Sr)�unittestZ	TestSuiteZ	makeSuiterrOrrrr�
test_suiteLs�rb�__main__)�__doc__rr raZ	distutilsrZ
distutils.logrZdistutils.errorsrZdistutils.filelistrrrrZtest.supportr	r
rZdistutils.testsrr(rZLoggingSilencerZTestCaserrOrbrLrrrr�<module>s0�#�