Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_compileall.cpython-39.opt-2.pyc

a

��g ��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlmZmZzddlmZdZWney�dZYn0ddlmZddlmZddlmZdd	lmZd
d�Zdd
�Zdd�ZGdd�d�Z Gdd�de ej!edd�Z"Gdd�de ej!edd�Z#Gdd�dej!�Z$Gdd�d�Z%Gdd�de%ej!edd�Z&Gdd�de%ej!edd�Z'Gdd �d �Z(Gd!d"�d"e(ej!edd�Z)Gd#d$�d$e(ej!edd�Z*e+d%k�r�e�,�dS)&�N)�mock�
skipUnless)�ProcessPoolExecutorTF)�support)�
script_helper)�without_source_date_epoch)�SourceDateEpochTestMetacCs|sd}tjj||d�S)N���optimization)�	importlib�util�cache_from_source)�script�opt�r�0/usr/local/lib/python3.9/test/test_compileall.py�get_pycsrcs�fdd�dD�S)Ncsg|]}t�|��qSr)r)�.0r�rrr�
<listcomp>&�zget_pycs.<locals>.<listcomp>�r��rrrrr�get_pycs%srcCs t�|�j}t�|�j}||kS�N)�os�stat�st_ino)Z	filename1�	filename2Zinode1Zinode2rrr�is_hardlink)sr!c@sheZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Ze�d#�d$d%��Zd&d'�Ze�d#�d(d)��Ze�d#�e�d*�d+d,���Zejd#d-d.�e�d*�d/d0���Zd1d2�Zd3d4�d5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%e&j'dIdJ��Z(d-S)K�CompileallTestsBasecCs�t��|_tj�|jd�|_tj�	|j�|_
t|jd��}|�d�Wd�n1sX0Ytj�|jd�|_
tj�	|j
�|_t�|j|j
�tj�|jd�|_t�|j�tj�|jd�|_t�|j|j�dS)N�_test.py�wzx = 123
z	_test2.pyZ_subdirz	_test3.py)�tempfile�mkdtemp�	directoryr�path�join�source_pathrr
r�bc_path�open�write�source_path2�bc_path2�shutil�copyfileZsubdirectory�mkdir�source_path3��self�filerrr�setUp2s
(zCompileallTestsBase.setUpcCst�|j�dSr�r0�rmtreer'�r5rrr�tearDown@szCompileallTestsBase.tearDowncCsLtj�|jd�|_t|jd��}|�d�Wd�n1s>0YdS)Nz_test_bad.pyr$zx (
)rr(r)r'�bad_source_pathr,r-r4rrr�add_bad_source_fileCsz'CompileallTestsBase.add_bad_source_filecCsht|jd��}|�d�}Wd�n1s,0Ytt�|j�j�}t�	dt
jjd|d@�}||fS)N�rb��<4sLLr���)
r,r+�read�intrrr*�st_mtime�struct�packrr
�MAGIC_NUMBER)r5r6�data�mtimeZcomparerrr�timestamp_metadataHs(�z&CompileallTestsBase.timestamp_metadatac	Csxzt�|jd�Wn ttfy2|�d�Yn0t�t�	���"|�
t�|j��Wd�n1sj0YdS)N)rArAz0filesystem doesn't support timestamps near 2**32�
r�utimer*�
OverflowError�OSErrorZskipTest�
contextlib�redirect_stdout�io�StringIO�
assertTrue�
compileall�compile_filer:rrr� test_year_2038_mtime_compilationPsz4CompileallTestsBase.test_year_2038_mtime_compilationc	Csxzt�|jd�Wn ttfy2|�d�Yn0t�t�	���"|�
t�|j��Wd�n1sj0YdS)N)� rWz+filesystem doesn't support large timestampsrKr:rrr�test_larger_than_32_bit_timesZsz1CompileallTestsBase.test_larger_than_32_bit_timescCs�tj�d�rt�d��t�|j�|j|�	��t
|jd��$}|��t
|�d�}Wd�n1sf0Yt
|jd��$}|�|�|�|�Wd�n1s�0Y|j|�	��tj|jddd�|j|�	��dS)N�SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setr>�wbFT��force�quiet)r�environ�get�unittestZSkipTest�
py_compile�compiler*�assertEqualrJr,r+rB�lenr-�assertNotEqualrT�compile_dirr'rS)r5�metadatar6�bcrrr�recreation_checkds
2
(z$CompileallTestsBase.recreation_checkcCs|�t�dtjjdd��dS)Nr@rr)rirErFrr
rGr:rrr�
test_mtimets�zCompileallTestsBase.test_mtimecCs|�d�dS)Ns)rir:rrr�test_magic_numberysz%CompileallTestsBase.test_magic_numbercCs|j|jfD] }zt�|�WqYq0q|�tj|jddd��|�tj�	|j�oftj�	|j��t�|j�|�tj
|jddd��|�tj�	|j�o�tj�	|j��t�|j�t�|j�|��|�
tj|jddd��|�
tj
|jddd��dS)NFTr[r)r+r/r�unlinkrSrTrUr*r(�isfilerfr'r=�assertFalser<)r5�fnrrr�test_compile_files}s6������z&CompileallTestsBase.test_compile_filescCs||�tj�|j��t���(}|�t�	t
�|j���Wd�n1sJ0Y|�
|��d�|�tj�|j��dS)Nz&Compiling ([^WindowsPath|PosixPath].*))rnrr(rmr+r�captured_stdoutrSrTrU�pathlib�Pathr*�assertRegex�getvalue)r5�stdoutrrr�test_compile_file_pathlike�s

6z.CompileallTestsBase.test_compile_file_pathlikecCsP|�tj�|j��|�tjt�	|j
�t�	d�dd��|�tj�|j��dS)NZ	ddir_pathr)�ddirr])rnrr(rmr+rSrTrUrrrsr*r:rrr�test_compile_file_pathlike_ddir�s�z3CompileallTestsBase.test_compile_file_pathlike_ddircCs�tjjj|jgd��"|�tjdd��Wd�n1s<0Ytjjj|jgd��.|��|�	tjdddd��Wd�n1s�0YdS)N�r(r�r]FT)�skip_curdirr\r])
�test�test_importlibr
Zimport_stater'rSrT�compile_pathr=rnr:rrr�test_compile_path�s0
�z%CompileallTestsBase.test_compile_pathcCs|tj�|jd�}tj�|d�}t�|�t|d��Wd�n1sH0Yt�|�|�tj�	tj�|d���dS)NrHr6r$�__pycache__)
rr(r)r'r2r,rTrUrn�exists)r5Zdata_dirZ	data_filerrr�test_no_pycache_in_non_package�s

z2CompileallTestsBase.test_no_pycache_in_non_packagecCsL|��t�t����"|�t�|j��Wd�n1s>0YdSr)	r=rOrPrQrRrnrTrUr<r:rrr�#test_compile_file_encoding_fallback�sz7CompileallTestsBase.test_compile_file_encoding_fallbackcCs�drdnd\}}tj|jd|d�tjj|j|d�}|�tj	�
|��tjj|j|d�}|�tj	�
|��tjj|j|d�}|�tj	�
|��dS)NF)rr)rr	T�r]�optimizer
)
rTrfr'rr
rr*rSrr(rmr.r3)r5r�r�cachedZcached2Zcached3rrr�
test_optimize�s
�
�
�z!CompileallTestsBase.test_optimizecCs�|�tj�|j��t���"}t�t	�
|j��Wd�n1sD0Y|���
�d}|�|d�|�tj�|j��dS)Nrz$Listing ([^WindowsPath|PosixPath].*))rnrr(rmr+rrqrTrfrrrsr'ru�
splitlinesrtrS)r5rv�linerrr�test_compile_dir_pathlike�s
0z-CompileallTestsBase.test_compile_dir_pathlikez&concurrent.futures.ProcessPoolExecutorcCs"tj|jddd�|�|j�dS�NT��r]�workers�rTrfr'rS�called�r5�	pool_mockrrr�test_compile_pool_called�sz,CompileallTestsBase.test_compile_pool_calledcCs@|�td�� tj|jdd�Wd�n1s20YdS)Nz%workers must be greater or equal to 0���)r�)ZassertRaisesRegex�
ValueErrorrTrfr'r:rrr�!test_compile_workers_non_positive�s�z5CompileallTestsBase.test_compile_workers_non_positivecCs,tj|jddd�|�|jddd�dS)NTrr�r�max_workers)rTrfr'rc�	call_argsr�rrr�test_compile_workers_cpu_count�sz2CompileallTestsBase.test_compile_workers_cpu_countzcompileall.compile_filecCs,tj|jdd�|�|j�|�|j�dS)NTr{)rTrfr'rnr�rS)r5�compile_file_mockr�rrr�test_compile_one_worker�sz+CompileallTestsBase.test_compile_one_workerN��newcCs"tj|jddd�|�|j�dSr�r�)r5r�rrr�$test_compile_missing_multiprocessing�sz8CompileallTestsBase.test_compile_missing_multiprocessingcCs�d}|j}td|d�D]>}tj�|d|���}tj�|d�}t�|�t�|j|�qt	j
�|�}tj
|jd|dd�|�tj�|��tj
|jd|d�|�tj�|��dS)N�rZdir_z	script.pyT)r]�	maxlevels)r'�rangerr(r)r2r0r1r*rr
rrTrfrnrmrS)r5�depthr(�i�sourceZpyc_filenamerrr�test_compile_dir_maxlevels�s
z.CompileallTestsBase.test_compile_dir_maxlevelsT)�parallelcCsddg}|j}g}|D]>}tj�||�}t�|�t�|dd�|�t�|dd��qtj	|jd||rjdnd	d
�|�
|�|D]�}|�
|�|j�|�tj
�|�}|t|jtj�d�}	t�|�\}
}
}tj�||	�}tjj
�|�}
|�|
j|�|�d|�d�t�|��q�dS)Nr}�foo�__init__r	�modzdef fn(): 1/0
fn()
Trr)r]rxr��")r'rr(r)r2r�make_script�appendrTrfrS�
startswithrr
rrd�sep�assert_python_failurer}r~Zget_code_from_pycrc�co_filename�assertIn�fsdecode)r5rxr��fullpathr(ZmodsZsubdirr�Zmodcode�modpath�_�err�expected_inZmod_code_objrrr�_test_ddir_onlys0
�
�
z#CompileallTestsBase._test_ddir_onlycCs|jddd�S)N�
<a prefix>F�rxr��r�r:rrr�test_ddir_only_one_workersz-CompileallTestsBase.test_ddir_only_one_workercCs|jddd�S)Nr�Tr�r�r:rrr�test_ddir_multiple_workers#sz.CompileallTestsBase.test_ddir_multiple_workerscCs|jddd�S)Nr	Fr�r�r:rrr�test_ddir_empty_only_one_worker'sz3CompileallTestsBase.test_ddir_empty_only_one_workercCs|jddd�S)Nr	Tr�r�r:rrr� test_ddir_empty_multiple_workers+sz4CompileallTestsBase.test_ddir_empty_multiple_workersc
Cs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}tjj|jg|dd��R�}t
j|d|d�t�|�\}}}tjj|dd��}	|�
|	t|t��d��|�|t|t��d��dS)N�r}�build�realr(r}�1 / 0rT)r]�stripdir��encoding�rr(r)r'�makedirsrr�rr
rrTrfr�r��str�sys�getdefaultencoding�assertNotIn)
r5r�r(rrhr��rc�outr�r�rrr�test_strip_only/s"
��z#CompileallTestsBase.test_strip_onlyc
Cs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}d}t
j|d|d�t�|�\}}}tjj||jg|�R�}	|�
|	t|t��d��dS)Nr�r}r��/fooT)r]�
prependdirr�)rr(r)r'r�rr�rr
rrTrfr�r�r�r�r�)
r5r�r(rrhr�r�r�r�r�rrr�test_prepend_onlyBs
�z%CompileallTestsBase.test_prepend_onlycCs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}tjj|jg|dd��R�}d}t
j|d||d�t�|�\}}}	tjj|g|dd��R�}
|�
|
t|	t��d��|�|t|	t��d��dS)	Nr�r}r�rr�T)r]r�r�r�r��r5r�r(rrhr�r�r�r�r�r�rrr�test_strip_and_prependQs(
���z*CompileallTestsBase.test_strip_and_prependcCsxgd�}tjj|jg|�R�}t�|�t�|dd�|�t��$t	j
|ddddd�Wd�n1sj0YdS)N)r}r�r�r(rxr}r�Tz/barr�)r]rxr�r�)rr(r)r'r�rr��assertRaisesr�rTrf)r5r�r(rrr�test_strip_prepend_and_ddirfs

�z/CompileallTestsBase.test_strip_prepend_and_ddirc
Cs�t�|jdd�}g}dD]}|�tjj||d��qddgddgddggd�g}|D]Z}tj|d	|d
�|D]@}|�	t
j�||��zt
�
||�Wqlty�Yql0qlqTdS)N�test_optimization�a = 0�r	rrr�r
rrrrTr�)rr�r'r�rr
rrTrUrSrr(rmrl�	Exception)r5rrh�	opt_level�test_combinations�opt_combinationrrr�!test_multiple_optimization_levelsos(��
�z5CompileallTestsBase.test_multiple_optimization_levelsc
Cs�tj�|jddd�}tj�|jddd�}tj�|jddd�}t�|�t�|�t�|�t�|dd�}t�|dd�}tj�|d	�}tj�|d
�}t�||�t�||�tj	�
|�}tj	�
|�}	tj|d|d�|�
tj�|��|�tj�|	��dS)
Nr}�dir�allowed�symlinks�
prohibited�test_allowedr��test_prohibited�test_allowed.py�test_prohibited.pyT)r]�
limit_sl_dest)rr(r)r'r�rr��symlinkrr
rrTrfrSrmrn�
r5Zallowed_pathZ
symlinks_pathZprohibited_pathZallowed_scriptZprohibited_scriptZallowed_symlinkZprohibited_symlinkZ
allowed_bcZ
prohibited_bcrrr�test_ignore_symlink_destination�s"


z3CompileallTestsBase.test_ignore_symlink_destination))�__name__�
__module__�__qualname__r7r;r=rJrVrXrirjrkrprwryr�r�r�r�r�r�patchr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�skip_unless_symlinkr�rrrrr"0sR

	


	r"c@seZdZdS)�CompileallTestsWithSourceEpochN�r�r�r�rrrrr��sr�)�	metaclassZsource_date_epochc@seZdZdS)�!CompileallTestsWithoutSourceEpochNr�rrrrr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�EncodingTestcCsdt��|_tj�|jd�|_t|jddd��$}|�d�|�d�Wd�n1sV0YdS)Nr#r$�utf-8r�z# -*- coding: utf-8 -*-
u
print u"€"
)	r%r&r'rr(r)r*r,r-r4rrrr7�s


zEncodingTest.setUpcCst�|j�dSrr8r:rrrr;�szEncodingTest.tearDowncCs>z0tj}tjt��dd�t_t�|j�W|t_n|t_0dS)N�asciir�)r�rvrQ�
TextIOWrapper�BytesIOrTrfr')r5Zorig_stdoutrrr�
test_error�s
zEncodingTest.test_errorN)r�r�r�r7r;r�rrrrr��sr�c@s�eZdZdd�Zejdd��Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Ze
dd��Zdd�ZddgfdddgfdddgffD]&\ZZZeefdd�Zee�de<q�d d!�Zd"d#�Ze
d$d%��Zd&d'�Zd(d)�Zejd*d+��Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@dA�Z'dBdC�Z(dDdE�Z)e*e+dF�dGdH��Z,e-�.dI�dJdK��Z/dLdM�Z0dNdO�Z1ejdPdQ��Z2dRdS�Z3dTdU�Z4dVS)W�CommandLineTestsBasecCsrt��|_|�tj|j�tj�|jd�|_	t�
|j	�tj�|j	d�|_t�
|j	dd�|_t�
|j	dd�|_dS)Nr�r�r�r	Zbar)r%r&r'Z
addCleanupr0r9rr(r)�pkgdirr2�pkgdir_cachedirrr��initfn�barfnr:rrrr7�s
zCommandLineTestsBase.setUpccsBtj}tj�|jd�}z|t_|j|d�VW|t_n|t_0dS)NZ
__testcache__)�
PYTHONPATHZPYTHONPYCACHEPREFIX)r��pycache_prefixrr(r)r')r5Z
old_prefix�
new_prefixrrr�temporary_pycache_prefix�s�
z-CommandLineTestsBase.temporary_pycache_prefixcCsgt���d�d�d�|�S)Nz-S�-mrT)rZ!optim_args_from_interpreter_flags)r5�argsrrr�
_get_run_args�s
����z"CommandLineTestsBase._get_run_argscOs4tj|�|�i|�ddi��\}}}|�d|�|S)N�PYTHONIOENCODINGr�r)r�assert_python_okrrc�r5rZenv_varsr�r�r�rrr�assertRunOK�s���z CommandLineTestsBase.assertRunOKcOs.tj|�|�i|�ddi��\}}}|||fS)Nrr�)rr�rr	rrr�assertRunNotOK�s���z#CommandLineTestsBase.assertRunNotOKcCs"tj�|�}|�tj�|��dSr)rr
rrSrr(r��r5ror(rrr�assertCompiled�sz#CommandLineTestsBase.assertCompiledcCs"tj�|�}|�tj�|��dSr)rr
rrnrr(r�rrrr�assertNotCompiled�sz&CommandLineTestsBase.assertNotCompiledcCsnt�|jdd�}|���B}|jfi|��|�|�|�|j�|�|j�Wd�n1s`0YdS)N�bazr	)	rr�r'rr
r
rr�r�)r5�bazfn�envrrr�test_no_args_compiles_path�s

z/CommandLineTestsBase.test_no_args_compiles_pathcCs�t�|jdd�}|���,}|jfi|��tj�|�}Wd�n1sJ0Yt�	|t
�
�dfd�t�|�j}|jfi|��t�|�j}|�
||�|jdi|��t�|�j}|�||�dS)Nrr	�<r�-f)r)rr�r'rr
rr
rrrL�timerrDrcre)r5rr�pycpathrI�mtime2rrr� test_no_args_respects_force_flag�s
*z5CommandLineTestsBase.test_no_args_respects_force_flagcCstt�|jdd�|��� }|jfi|��}Wd�n1s>0Y|�d|�|jdi|��}|�d|�dS)Nrr	sListing �-q)r)rr�r'rr
r�r�)r5r�noisyr]rrr� test_no_args_respects_quiet_flags
.z5CommandLineTestsBase.test_no_args_respects_quiet_flagZnormal�pycr�z	opt-1.pyc�-OZdoubleoptimizez	opt-2.pycz-OOcs~tj|ddd|jg�|�tj�|j��t�fdd�dD��}|�	tt�
|j��|�|��fdd�t�
|j�D��dS)	NrrTrc3s|]}|�tjj��VqdSr)�formatr��implementation�	cache_tag)r�base��extrr�	<genexpr>%s�z)CommandLineTestsBase.f.<locals>.<genexpr>)z__init__.{}.{}z	bar.{}.{}csg|]}|���r|�qSr)�endswith)rror"rrr)s
�z*CommandLineTestsBase.f.<locals>.<listcomp>)rrr�rSrr(r�r��sortedrc�listdirrn)r5r#�switch�expectedrr"r�f s��zCommandLineTestsBase.fZtest_pep3147_paths_cCsL|�dd|j�|�tj�|j��tgd��}|�tt�	|j��|�dS)Nz-br)�__init__.pyz__init__.pyczbar.pyzbar.pyc)
r
r�rnrr(r�r�r&rcr')r5r)rrr�test_legacy_paths-sz&CommandLineTestsBase.test_legacy_pathscCs||�d|j�|�tj�|j��tj�|jd�}|�tj�|��|�d|j�|�tj�|j��|�tj�|��dS)Nrr�)	r
r�rSrr(r�r�r)rn)r5Z
cachecachedirrrr�test_multiple_runs7sz'CommandLineTestsBase.test_multiple_runscCs�|�d|j�tj�|j�}t�|t��dfd�t�	|�j
}|�d|j�t�	|�j
}|�||�|�dd|j�t�	|�j
}|�||�dS)Nrrrr)
r
r�rr
rr�rrLrrrDrcre)r5rrIrrrr�
test_forceDszCommandLineTestsBase.test_forcecCs�tj�|jd�}t�|�t�|dd�}t�|dd�}|�dd|j�|�|�|�	tj�
tj�|d���|�d|j�|�|�|�|�dS)N�spamr�r	�hamrz-lr�)rr(r)r�r2rr�r
rrnr�r
)r5�
subpackage�	subinitfn�hamfnrrr�test_recursion_controlTs


z+CommandLineTestsBase.test_recursion_controlc	CsVtj�|jd�}tj�|d�}tj�|d�}|||fD]}t�|�q6tj�|d�}t�|dd�}t�|dd�}t�|dd�}|�dd|j�|�|�|�	tj�
tj�|d	���|�dd
|j�|�|�|�|�|�|�|�dd|j�|�|�|�|�|�|�|�|�|�dd|j�|�|�|�|�|�|�|�|�dS)
Nr/r0Zeggsr+r	Zeggrz-r 0r�z-r 1z-r 2z-r 5)rr(r)r�r�make_pkgr�r
rrnr�r
)	r5r1Zsubpackage2Zsubpackage3�pkgr2r3ZspamfnZeggfnrrr�test_recursion_limit`s8
�









z)CommandLineTestsBase.test_recursion_limitc	Csttj�|jd�}t�|�t�dtj�|d��t�dtj�|d��|�d|j�|�tj�|jdddd��dS)Nr/�.ZevilZevil2rr+)	rr(r)r�rr5r�r
r
)r5r6rrr�test_symlink_loop�s

�z&CommandLineTestsBase.test_symlink_loopcCs6|�|j�}|�d|j�}|�d|�|�d|�dS)Nrr)r
r�rerc)r5rr]rrr�
test_quiet�szCommandLineTestsBase.test_quietcCsTt�|jdd�|�d|j�\}}}|�d|j�\}}}|�d|�|�d|�dS)N�crunchyfrog�
bad(syntaxrz-qqr)rr�r�rrerc)r5r�r]Zsilentrrr�test_silent�s
z CommandLineTestsBase.test_silentcCs.|�ddd|j�|�|j�|�|j�dS)Nrz-xz
ba[^\\/]*$)r
r�rr�r
r�r:rrr�test_regexp�sz CommandLineTestsBase.test_regexpcCsvtj�|jd�}t�|�t�|dd�}t�|dd�}|�d|j|�|�	|j
�|�	|j�|�	|�|�	|�dS)NZfoo2r�r	�bar2r)rr(r)r'r2rr�r
r�r
r�r�)r5Zpkgdir2Zinit2fn�bar2fnrrr�test_multiple_dirs�s

z'CommandLineTestsBase.test_multiple_dirscCs8t�|jdd�|�ddd|j�\}}}|�|d�dS)Nr;r<r�-d�dinsdale�File "dinsdale)rr�r�rrt�r5r�r�r�rrr�test_d_compile_error�sz)CommandLineTestsBase.test_d_compile_errorcCs�t�|jdd�}|�ddd|j�t�|jdd�}tj�|�}t�|tj	�
|jd��t�|�tj|d	d
�\}}}|�
|d�dS)Nrzraise ExceptionrrBrC�bingz
import bazzbaz.pycF)�
__isolatedrD)rr�r�r
rr
rr�renamer(r)�remover�rt)r5rrorr�r�r�rrr�test_d_runtime_error�s
z)CommandLineTestsBase.test_d_runtime_errorcCsZ|�dtj�|jd�|j�\}}}|�|d�|�|d�|�tj�	t
j�|j
���dS)N�-i�
nosuchfilesrror.*nosuchfiles	Traceback)rrr(r)r'r�rtZassertNotRegexrnr�rr
rr�rErrr�test_include_bad_file�s�
�z*CommandLineTestsBase.test_include_bad_filecCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}ttj�|jd�d��H}|�tj�|jd�tj	�|�tj�|jd	�tj	�Wd�n1s�0Y|�
d
tj�|jd�|�|�|�|�|�|�|�|�|�dS)N�f1r	�f2�f3�f4�l1r$�f1.py�f2.pyrL)
rr�r�r,rr(r)r'r-�linesepr
r
r�r5rOrPrQrRrSrrr�test_include_file_with_arg�s:


z/CommandLineTestsBase.test_include_file_with_argcCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}ttj�|jd�d��,}|�tj�|jd�tj	�Wd�n1s�0Y|�
d	tj�|jd��|�|�|�|�|�|�|�|�dS)
NrOr	rPrQrRrSr$rUrL)
rr�r�r,rr(r)r'r-rVr
rr
rWrrr�test_include_file_no_arg�s:


z-CommandLineTestsBase.test_include_file_no_argcCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}tj|�d�ddg�}|j�|tj�	d	��t�
|�|�|�|�|�|�|�|�|�dS)
NrOr	rPrQrRrrL�-r�)
rr�r�Zspawn_pythonr�stdinr-rrV�encodeZkill_pythonrr
)r5rOrPrQrR�prrr�test_include_on_stdin�s



z*CommandLineTestsBase.test_include_on_stdincCs\t�|jdd�}|�d|j||j�\}}}|�|d�|�|�|�|j�|�|j�dS)NrGzsyntax(errorrMsrror)	rr�r�rr�r�rtrr
)r5Zbingfnr�r�r�rrr�!test_compiles_as_much_as_possible�s
�

z6CommandLineTestsBase.test_compiles_as_much_as_possiblecCs|�d�}|�|d�dS)NZbadfilenamesCan't list 'badfilename')r
rt)r5r�rrr�!test_invalid_arg_produces_message�s
z6CommandLineTestsBase.test_invalid_arg_produces_messagecCs�t�|jdd�tj�tj�|jd��}|�	d|j�t
|d��}|��}Wd�n1s^0Y|�t
�|dd�d�d	�|�	d
|j�t
|d��}|��}Wd�n1s�0Y|�t
�|dd�d�d�dS)NrOr	rTz --invalidation-mode=checked-hashr>���littler�z"--invalidation-mode=unchecked-hashr)rr�r�rr
rrr(r)r
r,rBrcrC�
from_bytes)r5r�fprHrrr�test_pyc_invalidation_mode�s�&&z/CommandLineTestsBase.test_pyc_invalidation_modezrequires multiprocessingcCs�t�|jdd�}g}td�D]F}tj�|jd�|��}t�|�t�|dd�}|�	t�|dd��q|�
|jdd�|�|�|D]}|�|�q�dS)Nr?r	r�zfoo{}r�z-j�0)rr�r'r�rr(r)rr2r�r
r
)r5r@�files�suffixr�ror6rrr�test_workerss

z!CommandLineTestsBase.test_workerszcompileall.compile_dircCsftjdtj|jdgd��:t��|�|j�|�	|j
ddd�Wd�n1sX0YdS)Nzsys.argvz-j0r�r�r�r)rr�r��
executabler'rT�mainrSr�rcr�)r5rfrrr�test_workers_available_coress�z1CommandLineTestsBase.test_workers_available_corescCs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}tjj|jg|dd��R�}d}|�
d|d||�t�|�\}}}	tjj|g|dd��R�}
|�|
t
|	t��d��|�|t
|	t��d��dS)	Nr�r}r�rr�z-sz-pr�)rr(r)r'r�rr�rr
rr
r�r�r�r�r�r�r�rrrr�s$
��z+CommandLineTestsBase.test_strip_and_prependc
Cs�tj�|jd�}t�|�t�|dd�}g}dD]}|�tj	j
||d��q0ddgddgddggd	�g}|D]j}|j|gd
d�|D��R�|D]D}|�tj�
|t|���zt�||�Wq�ty�Yq�0q�qldS)NZ
optimizationsr�r�r�r
rg�1�2)rgrnrocss|]}dt|�VqdS)z-oN)r�)r�nrrrr$@rzICommandLineTestsBase.test_multiple_optimization_levels.<locals>.<genexpr>)rr(r)r'r�rr�r�rr
rr
rSrmrCrlr�)r5r(rrhr�r�r�rrrr�1s0
��
�z6CommandLineTestsBase.test_multiple_optimization_levelsc
Cs�tj�|jddd�}tj�|jddd�}tj�|jddd�}t�|�t�|�t�|�t�|dd�}t�|dd�}tj�|d	�}tj�|d
�}t�||�t�||�tj	�
|�}tj	�
|�}	|�|d|�|�tj�
|��|�tj�
|	��dS)Nr}r�r�r�r�r�r�r�r�r�z-e)rr(r)r'r�rr�r�rr
rr
rSrmrnr�rrrr�Hs"


z4CommandLineTestsBase.test_ignore_symlink_destinationcCs|�|jdd�dS)N�-o 1�--hardlink-dupes)rr'r:rrr�test_hardlink_bad_argsasz+CommandLineTestsBase.test_hardlink_bad_argsc
Cs�dD]�}t����}|j|d���t�|dd�}t|�}gd�}|rL|�d�|j|g|�R�|�t	|d|d�|�|�t	|d|d	�|�|�t	|d|d	�|�Wd�n1s�0YWd�q1s�0YqdS)
N)TF��deduprr�)rz-o 0rqz-o 2rrrrr)
r%�TemporaryDirectory�subTestrr�rr�r
rcr!)r5rur(r�pycsrrrr�
test_hardlinkfs

z"CommandLineTestsBase.test_hardlinkN)5r�r�r�r7rO�contextmanagerrrr
rr
rrrrr�namer#r(r*�localsr,r-r.r4r7rr�r9r:r=r>rArFrKrNrXrYr^r_r`rfr�_have_multiprocessingrjrr�rmr�r�r�rsryrrrrr��sb


	


�


"




	



r�c@seZdZdS)�CommandLineTestsWithSourceEpochNr�rrrrr~|sr~c@seZdZdS)�CommandLineTestsNoSourceEpochNr�rrrrr�src@s�eZdZdd�Zejdd��Zd#dd�Zdd	d
d�dd
�Zdd�Z	d$dd�Z
dd�Zdd�Zd%dd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"S)&�HardlinkDedupTestsBasecCs
d|_dSrrzr:rrrr7�szHardlinkDedupTestsBase.setUpccs>t���"}||_|Vd|_Wd�n1s00YdSr)r%rvr()r5r(rrr�temporary_directory�s
z*HardlinkDedupTestsBase.temporary_directoryrcCst�|j||�Sr)rr�r()r5�coder{rrrr��sz"HardlinkDedupTestsBase.make_scriptTrF)rur�r\cCstj|jd|||d�dS)NT)r]r��hardlink_dupesr\)rTrfr()r5rur�r\rrrrf�s�z"HardlinkDedupTestsBase.compile_dirc	Cs�|����|�d�|�t��$tj|jdddd�Wd�n1sH0Y|�t��(tj|jdddgdd�Wd�n1s�0YWd�n1s�0YdS)N�passTr)r]r�r�)r�r�r�r�rTrfr(r:rrr�
test_bad_args�s

�$�z$HardlinkDedupTestsBase.test_bad_argscCs4g}|r|�d�|�d�|r*|�d�d�|�S)Nz'module docstring'zx = 1z
assert x == 1�
)r�r))r5�	docstring�	assertion�linesrrr�create_code�s


z"HardlinkDedupTestsBase.create_codeccs2dD](}dD]}|j||d�}|||fVqqdS)N)FT�r�r�)r�)r5r�r�r�rrr�
iter_codes�sz!HardlinkDedupTestsBase.iter_codesc
Cs�|��D]�\}}}|j||d���|���v|�|�}t|�}|jdd�|�t|d|d��|�t|d|d��|�t|d|d��Wd�n1s�0YWd�q1s�0YqdS)Nr�Frtrrr)r�rwr�r�rrfrnr!)r5r�r�r�rrxrrr�
test_disabled�s

z$HardlinkDedupTestsBase.test_disabledcCsft|�}|�t|d|d�|�|�t|d|d�|oB|�|�t|d|d�|�dS)Nrrr)rrcr!)r5rr�r�rxrrr�check_hardlinks�s�
��z&HardlinkDedupTestsBase.check_hardlinksc
Cs�|��D]�\}}}|j||d��X|���0|�|�}|��|�|||�Wd�n1s`0YWd�q1s~0YqdS)Nr�)r�rwr�r�rfr�)r5r�r�r�rrrrry�s

z$HardlinkDedupTestsBase.test_hardlinkc
Cs�dD]�}|j|d��~|���V|�|���}|j|d�t||d�}t||d�}|�t||��Wd�n1sz0YWd�q1s�0YqdS)N))rr)rr)rr)�opts�r�rr)rwr�r�r�rfrrSr!)r5r�r�pyc1�pyc2rrr�test_only_two_levels�s
z+HardlinkDedupTestsBase.test_only_two_levelscCsn|���R|�|���}|jgd�d�t|d�}t|d�}|�t||��Wd�n1s`0YdS)N)rrrrr�rr)r�r�r�rfrrSr!)r5rr�r�rrr�test_duplicated_levels�s


z-HardlinkDedupTestsBase.test_duplicated_levelscCs�|����|�d�}|��|�|�t|�}t�|d�j}|�d�}|jddgdd�|�|t�|d�j�|�	t
|d|d��|�|t�|d�j�|�t
j|d|ddd��Wd�n1s�0YdS)	Nr�r�print(0)rT)r�r\r��shallow)r�r�rfr�rrrrrcrSr!rern�filecmp�cmp�r5rrx�inoderrr�test_recompilation�s



z)HardlinkDedupTestsBase.test_recompilationcCs�|����|j|��dd�}|��|�|�t|�}t�|d�j}|jddd�}t	j
dddd|jd	�|�|t�|d�j�|�|t�|d
�j�|�
t|d|d
��|�
tj|d|d
dd
��Wd�n1s�0YdS)N�module)r{rr�rz-cz
import moduleF)rHrrrTr�)r�r�r�rfr�rrrrrrr(rcrnr!r�r�r�rrr�test_imports

�z"HardlinkDedupTestsBase.test_importN)r)FF)FF)r�r�r�r7rOrzr�r�rfr�r�r�r�r�ryr�r�r�r�rrrrr��s


	
		
r�c@seZdZdS)�!HardlinkDedupTestsWithSourceEpochNr�rrrrr�(sr�c@seZdZdS)�HardlinkDedupTestsNoSourceEpochNr�rrrrr�/sr��__main__)-rTrOr��importlib.utilrrQrrrrar0rEr�r%Ztest.test_importlib.utilr}rr`rr�concurrent.futuresrr}�ImportErrorrZtest.supportrZtest.test_py_compilerrrrr!r"ZTestCaser�r�r�r�r~rr�r�r�r�rlrrrr�<module>s�
n��>����


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists